Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to view application logging on Azure

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?

like image 885
Greg Gum Avatar asked Sep 30 '18 13:09

Greg Gum


People also ask

Where is the application event log in 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.

How do I check application logs?

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.

How do you check logs in application insights in Azure portal?

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.


1 Answers

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>();
like image 172
Kirk Larkin Avatar answered Sep 29 '22 09:09

Kirk Larkin