Troubleshooting App Service Logs

This guide helps you understand and troubleshoot issues related to application logs generated by Azure App Service.

Understanding App Service Log Types

Azure App Service provides several types of logs that can be invaluable for diagnosing application and platform issues. The primary log types include:

Enabling and Configuring Logs

Before you can troubleshoot, you need to ensure logging is enabled and configured appropriately. You can manage these settings through the Azure portal.

Application Logging

To enable application logging:

  1. Navigate to your App Service in the Azure portal.
  2. In the left-hand menu, under "Monitoring," select "App Service logs."
  3. Under "Application Logging," choose "On."
  4. Select the "Level" to log (e.g., Error, Warning, Information, Verbose). Verbose captures the most detail but can impact performance.
  5. Choose a destination for your logs:
    • Log stream: View logs in real-time directly in the portal.
    • Storage container: Store logs in an Azure Blob Storage container for longer-term retention and analysis.
    • Filesystem: Store logs locally within the App Service's file system (limited retention).

Web Server Logging

To enable web server logging:

  1. In the "App Service logs" section, enable "Web server logging."
  2. Choose a destination and retention period.

Detailed Error Messages and Failed Request Tracing

These can be enabled similarly in the "App Service logs" section. For Failed Request Tracing, you'll need to configure specific rules.

Accessing and Analyzing Logs

Log Stream

The "Log stream" feature provides a real-time view of your application and web server logs. This is excellent for immediate debugging during development or when actively troubleshooting an issue.

The Log Stream is useful for quick checks but is not intended for long-term storage or complex analysis.

Blob Storage

Storing logs in Blob Storage is the recommended approach for production environments. This allows you to:

Logs are typically stored in containers named logservices within your storage account. The structure usually involves folders for the App Service name, type of log, and date/time.

Local File System

Logs written to the local file system can be accessed via the Kudu console (https://your-app-name.scm.azurewebsites.net/) under the D:\home\LogFiles directory.

D:\home\LogFiles\
├── Application
│   ├── AppServiceHTTPPlatformHandler.log
│   └── AppServiceHTTPPlatformHandler.trace
├── DetailedErrors
├── eventlog.xml
├── httpPlatformHandler.log
├── npm
├── RecordList
├── Request
│   └── iisnode.log
├── W3SVC1
│   └── u_exYYMMDD.log  (Web server logs)
└── WordPress
    └── ...
            

Common Troubleshooting Scenarios

Application Crashes or Unresponsiveness

What to check:

High CPU or Memory Usage

What to check:

HTTP Errors (e.g., 500, 404)

What to check:

Deployment Issues

What to check:

Best Practices

Remember to restart your App Service after making changes to logging configurations if prompted or if changes don't appear immediately.