I have an aspnetcore 2.1 app running on azure.
I now want to view logging information to debug an issue that occurs only on Azure.
In the app, an ILogger<>
is injected into the class and used:
this._logger.LogInformation("constructor**********************************************");
If I run the app in VS, I can see the output in both the debug output window, as well as the asp.net core web server output window.
I then publish and go on Azure and enable the Log Stream and view it. I do see information appearing in the log stream, but it is just the request information from IIS. I don't see any other log messages.
Is there anything else I need to do to see the logging information on Azure?
In the Azure portal, open the app in App Services. Select Diagnose and solve problems. Select the Diagnostic Tools heading. Under Support Tools, select the Application Events button.
Click on the Windows Start Button. Right-click on Computer and select Manage. In the Computer Management dialog, expand System Tools | Event Viewer | Windows Logs. Select Application Log.
View logs in Application InsightsGo to Application Insights resource in your resource group. Go to Logs under Monitoring section. Click on traces eye button to get log traces. Select Time Range and click Run.
You can use Microsoft.Extensions.Logging.AzureAppServices. The package describes itself as:
Logger implementation to support Azure App Services 'Diagnostics logs' and 'Log stream' features.
Once you've installed the package, you'll need to update the logger configuration to use this new provider, which is usually done in Program.cs
, like this:
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.ConfigureLogging(loggingBuilder =>
{
loggingBuilder.AddAzureWebAppDiagnostics();
})
...
.UseStartup<Startup>();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With