Microsoft Azure: Configure Azure App Service Logging

Azure App service logging are the output of runtime trace statement in the different app code. logging feature will help you might only want to see a logged message when a particular level of error has occurred, While developing a Web App or an API, this can be very useful in order to debug it.

Azure provides built-in diagnostics to assist with debugging an App service App. In this article, you will learn what are the different types of diagnostics logging and steps to enable in Azure Portal. I have shared in my previous article details information to create a web app using the Azure portal and use the same application for demo.
Enable diagnostics logging for apps in Azure App Service

Types of Azure App service Logging

Azure provides the below-logging feature in the new Azure portal and all the logging features will support the Windows platform and some of the logging will support Linux as well. Logs can be stored and located for accessing information in the portal.
  1. Application Logging (Filesystem and Blob)
  2. Web Server logging (Filesystem and Storage)
  3. Detailed Error Message
  4. Failed request tracing

Step to Enable Application logging

Application logs message generated by the application. There are two options available in application logging as Filesystem and Blob. Contains one or more text files. The format of the log messages depends on the logging provider and access logging in the following directory - /Logfile/Application/

Filesystem

The Filesystem option is for temporary debugging purposes and turns itself off in 12 hours.

Blob

The Blob option is for long-term logging and needs a blob storage container to write logs to.

Error Level

Application error detail fall into the following error level
  1. Error – Included category by Error and Critical
  2. Warning - Included category by Warning, Error, and Critical
  3. Information - Included category by Info, Warning, Error, and Critical
  4. Verbose - Trace, Debug, Info, Warning, Error, Critical (all categories)
You can follow the below steps to enable application logging for Windows apps in the Azure portal.

Step 1: Navigate to the Azure portal and select your Web app and select App Service logs.
Enable diagnostics logging for apps in Azure App Service

Step 2: Select on either Application logging Filesystem or Blob or both, in this demo I have enabled Application logging as a File system.
Step 3: You can also set the Error level as Error, warning, information, verbose.
Step 4: Select Save Options.

Step to Enable Web Server logging

Web Server Logging also having two different types of storage and File Systems, Raw HTTP request data in the W3C extended log file format. Each log message includes data such as the HTTP method, resource URI, client IP, client port, user agent, response code, and store log file in the /LogFiles/http/RawLogs/. You can follow the below steps to enable webserver logging

Step 1: Navigate to the Azure portal and select your Web app and select App Service logs.

Enable diagnostics logging for apps in Azure App Service

Step 2: Select on either Web server logging Filesystem or Blob, in this demo I have enabled server logging as a File system.
Step 3: Provide Quota and Retention Period (Days), set the number of days the logs should be retained.
Step 4: Once all the details filled and click on save options

Detailed Error Message

Detail Error Message selects as ON, they will generate an error message as a File system and Copies of the .htm error pages that would have been sent to the client browser. For security reasons, detailed error pages shouldn't be sent to clients in production, but App Service can save the error page each time an application error occurs that has HTTP code 400 or greater and file will store in the directory is http://logfiles/DetailedErrors/

Enable diagnostics logging for apps in Azure App Service

Failed request tracing

The Failed request tracing including a trace of the IIS components used to process the request and the time taken in each component. It's useful if you want to improve site performance or isolate a specific HTTP error. The file format is XML files and an XSL file. You can view the formatted XML files in the browser and a file store directory is /LogFiles/W3SVC#########/

Enable diagnostics logging for apps in Azure App Service

Download Log File

All the different logging has Specify logs stored in the App Service file system, the easiest way is to download the ZIP file in the browser at

Windows apps: https://<app-name>.scm.azurewebsites.net/api/dump

Linux/container apps: https://<app-name>.scm.azurewebsites.net/api/logs/docker/zip


Summary

In this article, you have learned detail about the Azure logging feature and how to enable different logging uses the Azure portal, Will share in the next article about implementing logging and send log messages to the application logs. If you have any questions/feedback/ issues, please write them in the comment box.

0 Comments

Featured Post

Improving C# Performance by Using AsSpan and Avoiding Substring

During development and everyday use, Substring is often the go-to choice for string manipulation. However, there are cases where Substring c...

MSDEVBUILD - English Channel

MSDEVBUILD - Tamil Channel

Popular Posts