Are upgrading from ASP.NET Core 2.1 to ASP.NET Core 2.2 and following the official documentation guide.
Got a problem with writing the new logging configuration in Startup.cs. Specifically problems on how to handle the AzureWebAppDiagnostics.
The old configuration consisted of the following configuration:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
...
loggerFactory.AddApplicationInsights(app.ApplicationServices);
loggerFactory.AddAzureWebAppDiagnostics(
new AzureAppServicesDiagnosticsSettings
{
OutputTemplate = "{Timestamp:yyyy-MM-dd HH:mm:ss zzz} [{Level}] {RequestId}-{SourceContext}: {Message}{NewLine}{Exception}"
}
);
}
Both the AddAzureWebAppDiagnostics and the AzureAppServicesDiganosticsSettings is marked as obsolete. The later suggests to use AzureBlobLoggerOptions instead. The guide states that the logging config should be moved to something like this:
public void ConfigureServices(IServiceCollection services)
{
...
services.AddLogging(builder => builder
.AddConsole()
.AddAzureWebAppDiagnostics());
...
}
However I have no clue on how to properly add the configuration to the ILoggingBuildler AND as an extra bonus, the AzureBlobLoggerOptions does no allow for a custom OutputTemplate. The AddApplicationInsights is also missing from the ILoggingBuilder.
Any suggestions on how to get this working like it used to be?
Insights is a bit slow to the party. There is a new package with support for the logging builder eg
Without that you will need to use the Obsolete way.