Enabling AppServiceAppLogs & AppServiceHTTPLogs diagnostic settings in app services

This post has been republished via RSS; it originally appeared at: New blog articles in Microsoft Community Hub.

Azure provides built-in diagnostics to assist with debugging an App Service app. You can send your logs from your App Service to Storage Accounts, Event Hubs, or Log Analytics.

 

This blog will guide you step-by-step to enable AppServiceHTTPLogs , AppServiceAppLogs and view them in Log Analytics.

 

Step 1:

Go to Azure Portal > App Service > Diagnostic Settings and enable the required settings you would like to send to the destination . In this blog I have taken an example of HTTP Logs and App Service Application Logs in a Windows App Service ( .Net Core ).

 

AmritpalSinghNaroo_4-1681311056514.png

 

You can refer this doc for more details on supported log types.

 

Step 2:

In your application code you can use the usual logging options and send log messages to application logs. By default, ASP.NET Core uses the Microsoft.Extensions.Logging.AzureAppServices logging provider. For more information, see ASP.NET Core logging in Azure.

 

Below is the code snippet of the logging I am doing in my .Net Core MVC webapp.

 

AmritpalSinghNaroo_1-1681311032171.png

 

 

Step 3:

Go to Azure Portal > Log Analytics workspace > Logs and query the AppServiceAppLogs table and you can see the logs being sent. You can use different levels of logging such as Error, Information, Verbose and etc. in your application and this will show up in your logs in Log Analytics under the “Level” field. You can filter out logs based on the level:

 

AmritpalSinghNaroo_5-1681311131254.png

 

Similarly, you can also query AppServiceHTTPLogs:

 

AmritpalSinghNaroo_6-1681311161831.png

 

Sample Queries in Log Analytics:

 

AppServiceAppLogs

| where TimeGenerated >ago(10m)

 

AppServiceHTTPLogs

| where TimeGenerated >ago(10m)

 

 

More information:

 

If you have any other questions, feel free to comment below!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.