Enable application logging
- To enable application logging for Windows apps in the Azure portal, navigate to your app and select App Service logs.
- Select On for either Application Logging (Filesystem) or Application Logging (Blob), or both.
- The Filesystem option is for temporary debugging purposes, and turns itself off in 12 hours. The Blob option is for long-term logging, and needs a blob storage container to write logs to. The Blob option also includes additional information in the log messages, such as the ID of the origin VM instance of the log message (InstanceId), thread ID (Tid), and a more granular timestamp
Enable web server logging
- To enable web server logging for Windows apps in the Azure portal, navigate to your app and select App Service logs.
- For Web server logging, select Storage to store logs on blob storage, or File System to store logs on the App Service file system.
- In Retention Period (Days), set the number of days the logs should be retained.
- For logs stored in the App Service file system, the easiest way is to download the ZIP file in the browser at:
- Linux/container apps: https://<app-name>.scm.azurewebsites.net/api/logs/docker/zip
- Windows apps: https://<app-name>.scm.azurewebsites.net/api/dump
Log detailed errors
- To save the error page or failed request tracing for Windows apps in the Azure portal, navigate to your app and select App Service logs.
- Under Detailed Error Logging or Failed Request Tracing, select On, then select Save.
Note: Both types of logs are stored in the App Service file system. Up to 50 errors (files/folders) are retained. When the number of HTML files exceed 50, the oldest 26 errors are automatically deleted.
Add log messages in code
- ASP.NET applications can use the System.Diagnostics.Trace class to log information to the application diagnostics log. For example:
System.Diagnostics.Trace.TraceError("If you're seeing this, something bad happened");
- By default, ASP.NET Core uses the Microsoft.Extensions.Logging.AzureAppServices logging provider.
Enable Stream logs
Navigate to your app and select Log stream