I want to set up logging for my azure deployed ASP.NET Core web app. I can see the logs just fine when running the app locally, but when deployed to Azure the Log Stream doesn’t show anything. In Azure I have my Application logging turned on with the level set to ‘Information’.
Here is my Program.cs
:
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
// configure logging
var logger = LoggerFactory.Create(logging =>
{
logging.ClearProviders();
logging.AddConsole();
logging.AddDebug();
logging.AddAzureWebAppDiagnostics(); // Add Azure Web App logging
}).CreateLogger<Program>();
// other code
}
And my appsettings.json
:
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
},
"AzureAppServices": {
"File": {
"IsEnabled": true,
"LogLevel": {
"Default": "Information"
}
}
},
"Blob": {
"IsEnabled": true,
"LogLevel": {
"Default": "Information"
}
},
"Table": {
"IsEnabled": true,
"LogLevel": {
"Default": "Information"
}
}
}
I’ve tried to find solutions elsewhere but none seem to work.
New contributor
Eric is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.