I'm trying to configure custom logging in my ASP.NET Core MVC app. The app is hosted on Azure App Service on Linux (free tier). The log files are not appearing, what am I doing wrong?
My configuration:
Following ASP.NET Core logging documentation (https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-3.1#azure-app-service-provider), I've added an Azure App Service logging provider to my app:
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureLogging(logging =>
{
logging.ClearProviders();
logging.AddAzureWebAppDiagnostics();
})
.ConfigureServices(serviceCollection => serviceCollection
.Configure<AzureFileLoggerOptions>(options =>
{
options.FileName = "azure-diagnostics-";
options.FileSizeLimit = 10 * 1024;
options.RetainedFileCountLimit = 5;
})
)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseUrls("http://*:8080");
webBuilder.UseStartup<Startup>();
});
The logging configuration in app.settings:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}
I'm logging an info, warning and an error in my controller.
Following the Azure documentation (https://docs.microsoft.com/en-us/azure/app-service/troubleshoot-diagnostic-logs#enable-application-logging-linuxcontainer), I've enabled logging to file system at Azure App -> App Service Logs:
My app gets deployed fine and works. I'm expecting to find a log file with names 'azure-diagnostics' somewhere in the file system of the app. I've checked the file system by going to Azure App -> SSH and running:
find . -name '*azure-diagnostics*'
which doesn't return anything. I've also checked the file system using Kudu and VS Cloud Explorer, the files are not there. If I add the console logging provider, the logs appear in the standard Azure log files just fine. What am I missing here?