I have asp.net core 3.1 application. These are my settings for logging:
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.ConfigureLogging(logging =>
{
logging.AddAzureWebAppDiagnostics();
logging.AddConsole();
logging.AddDebug();
})
.UseStartup<Startup>();
And in code I use this _logger.LogInformation()
. I can see logs in console when I run the app locally, but the question is how I can see it on my app service on Azure Portal?
CodePudding user response:
Configuring Logging to work with Azure App Service
- The package you need is
Configure Logging in Azure App Service
- Next, on the right, toggle Application Logging (Filesystem) to enable it.
- When you enable logs, you'll be able to set how verbose of messages you want to capture. If this is your first test, I recommend using Information so you'll see all traffic to your site. Later, you might want to only look at Warnings or Errors. Be sure to Save your selection.
Choose Log Level.
Now click on Log stream on the left to attach to your application's logs.
Navigate to your site and you should see log messages corresponding to the requests you're making to the application.
- View your Azure App Service live log stream.
Please refer Configuring Logging in Azure App Services for more details.