Whilst upgrading from AspNetCore 2.0 to 2.1, some of the StartUp configuration had changed slightly and part of the upgrade required me to refactor code into the webhost builder. However as a result I didn’t quite do everything and after deploying to azure web app, I was hit with a 502 response. An exception being thrown in main(). This was a problem because it was happening before it could get to my logging initialization and therefore no logging was happening.
So in order to debug Azure Web App AspNetCore startup issues we need to enable stdout logging which throws all exceptions to a log file. This method of logging is unfiltered and gets heavy very quickly. Therefore it is inadvisable to keep it turned on.
Enable STDOUT on Azure Web App
- Go to your azure web app in Azure Portal
- Open Kudu Console
- Using the navigation bar at the top of the page, open Debug console and select CMD
- Navigate to folder site > wwwroot
- Edit the web.config
- Set stdoutLogEnabled to
trueand stdoutLogFile to
- Select Save
- Make a request to the application url
- In Kudu, navigate to the LogFiles folder
- Open the new files marked with stdout
- When the log file opens, the error is displayed.
- you must disable stdoutLogEnabled by setting to false when you are done