Jump to content

Enabling AppServiceAppLogs & AppServiceHTTPLogs diagnostic settings in app services

Featured Replies

Posted

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 ).

 

 

 

658x166vv2.png.33c9f14460a85e70400046a8c92c4bf9.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.

 

 

 

657x318vv2.png.f37b40a85e24f146babd4ecb81d31ba5.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:

 

 

 

659x132vv2.png.977cb00ca8a04f6ca7d582cf13486644.png

 

 

 

Similarly, you can also query AppServiceHTTPLogs:

 

 

 

659x185vv2.png.05c444a39c5a6361772e873587fc4a18.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!

 

Continue reading...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...