Capture ILogger logs of an asp.net core application on an azure app service

3.4k views Asked by At

I am working on an asp.net core web application.

This application is hosted on an azure app service.

This application generates log on standard output (dotnet run command). This log comes from ILogger.

How can i see this logs in azure portal ?

Thanks

2

There are 2 answers

0
Ryan Hill On BEST ANSWER

Check out the following docs

The first doc shows how to use Application Insights for logging. You can capture telemetry such as request duration, dependencies involved in a given request, exceptions, etc.

The second doc shows the various ways to configure ILogger and since ASP.NET Core uses Microsoft.Extensions.Logging.AzureAppService by default, all you have to is enable the logging on the App Serivce, the third doc.

0
Adam Hulek On

In the Diagnostic Settings of your Web App you can enable "App Service Application Logs" to be sent to some Log Analytics Workspace: Enabling AppServiceAppLogs & AppServiceHTTPLogs diagnostic settings in app services

When you write a log entry with the ILogger, it should appear in the AppServiceAppLogs table. You can query this table using KQL in Log Analytics Workspace or Azure Monitor.