I am trying to enable application logs in azure. I have a dummy Net Core 2 App running in an appService in azure.
and basically my goal is to see the trace messages in the log stream and in the application log files but I have not found the right way to do this.
One of the challenge I have found reading other posts is that they assume a web config in place.
Run
dotnet add package EntityFramework Microsoft.Extensions.Logging.AzureAppServices
to install logging extension to your project.Program.cs file for reference:
You could get answer from this blog. The following is the snippet from the blog.
You need to use "Microsoft.Extensions.Logging.AzureAppServices" package and then register the logging provider for azure using code below.
The documentation for ASP.NET Core 2.2 is here.
Firstly, enable Application Logging and choose the appropriate level:
This may be all you need to do to diagnose any problems. But if you want log messages and see them, install the Microsoft.Extensions.Logging.AzureAppServices NuGet package.
Then, configure logging:
Now you can inject and use ILogger:
Then in the Azure App Service, click on Log stream: