Discuss Diagnostics Logging In WebApps Of Azure App Service

In this article, I am discussing about Azure diagnostics logging, Microsoft Azure provides built-in diagnostics to assist with debugging an app Service Web app. In this article, I will explain how to enable diagnostic logging in your Application, as well as how to access the information logged by Azure.App Service Web apps, which provides the diagnostic functionality for logging information from both the Web Server and the Web Application. These are logically called-

  • Web Server diagnostics
  • Application diagnostics

In Web Server Diagnostics - You can enable or disable the following logs-

  • Detailed Error Logging
    Detailed error information for HTTP status codes, which indicates a failure (status code 400 or greater). This may contain information, which can help to determine why the Server returned the error code.

  • Failed Request Tracing
    Detailed information on the failed requests, including a trace of the IIS components used to process the request and the time taken in each component. This can be useful, if you are attempting to increase the site performance etc.

  • Web Server Logging
    Information about HTTP transactions, using W3C extended log file format. This is useful when determining the overall site metrics such as the number of requests handled or how many requests are from a specific IP address came etc.

  • In Application Diagnostics
    It allows you to capture the information produced by a Web Application. ASP.NET Applications can use the System.Diagnostics. It traces class to log the information to the Application diagnostics log. 

    For example -
    System.Diagnostics.Trace.TraceError("If you found this, it means something wrong").
At runtime, you can retrieve these logs to help with troubleshooting of Webapp.

App Service Web apps also logs the deployment information when you publish the content to a Web app in Azure. This happens automatically and there are no configuration settings for deployment logging.

Deployment logging allows you to determine why a deployment failed. See the link given below on how to enable Diagnostics Logging in Azure Portal-





The classic portal Web app Configure tab also has the additional settings for the Application diagnostics.
  • File system
    It stores the Application diagnostics information to the Web app file system. These files can be accessed by FTP or downloaded as a zip by using Azure PowerShell or Azure Command-Line Interface.

  • Table storage
    It stores the Application diagnostics information in the specified Azure Storage account and the table name, which is specified.

  • Blob storage
    It stores the Application diagnostics information in the specified Azure Storage Account and blob container, which you specified.

  • Retention period
    By default, logs are not automatically deleted from blob storage. Select set retention and enter the number of days to keep logs, if you want to automatically delete the logs. Diagnostics can also be enabled from Azure PowerShell, using the Set-AzureWebsite cmdlet.
Diagnostic information is stored to the Web app file system, which can be accessed directly, using File Transfer Protocol. It can also be downloaded as a zip file, using Azure PowerShell or Azure Command-Line Interface.

The directory structure that the logs are stored are given below-
  • Application logs
    /LogFiles/Application/. This folder contains one or more text files, which contains the information produced by an Application logging.

  • Failed Request Traces
    /LogFiles/W3SVC#########/. This folder contains XSL file and one or more XML files. Ensure that you download XSL file into the same directory as XML file(s) because XSL file provides the functionality for formatting and filtering the contents of XML file(s), when viewed in the browser.

  • Detailed Error Logs
    /LogFiles/DetailedErrors/. This folder contains one or more .htm files, which provides an extensive information for any HTTP errors, which have occurred in the Web app.

  • Web Server Logs
    /LogFiles/http/RawLogs. This folder contains one or more text files formatted using the W3C extended log file format.

  • Deployment logs
    /LogFiles/Git. This folder contains log generated by the internal deployment processes used by Azure Web apps, as well as logs for Git deployments also.
Download with Azure PowerShell - To download the log files, start a new instance of Azure PowerShell and use the command, given below-

Save-AzureWebSiteLog -Name webappname

This will save the logs for the web app specified by the -Name parameter to a file named logs.zip in the current directory.

Application diagnostics stores information in a specific format for .NET Applications, depending on whether you store logs to the file system, table storage, or blob storage. The base set of data stored is the same across all the three storage types - the date and time; the event occurred, the process ID that produced the event, the event type (information, warning, error) and the event message.

File system

Each line logged to the file system will be in the format, given below-

{Date} PID[{process id}] {event type/level} {message}

Next Recommended Readings