Closed
Description
Context: I've been working to upgrade some applications to .NET Core 3.0 - this has led me to update a number of packages as well, including App Insights.
Previously the recommendation was to configure AppInsights and Serilog together using the IHostBuilder
in Program.cs
, e.g.:
return builder
.UseApplicationInsights()
.UseSerilog((context, configuration) =>
{
var telemetry = TelemetryConfiguration.Active;
configuration
.ReadFrom.Configuration(context.Configuration)
.MinimumLevel.Override("Microsoft.AspNetCore.Authentication", LogEventLevel.Information)
.Enrich.FromLogContext()
.WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}", theme: AnsiConsoleTheme.Literate)
.WriteTo.ApplicationInsights(telemetry, new TraceTelemetryConverter());
},
writeToProviders: true);
But after upgrading to the latest AppInsights, I'm starting to get the warnings (as errors):
'ApplicationInsightsWebHostBuilderExtensions.UseApplicationInsights(IWebHostBuilder)' is obsolete: 'This method is deprecated in favor of AddApplicationInsightsTelemetry() extension method on IServiceCollection.'
and
'TelemetryConfiguration.Active' is obsolete: 'We do not recommend using TelemetryConfiguration.Active on .NET Core. See https://github.com/microsoft/ApplicationInsights-dotnet/issues/1152 for more details'
The first can be overcome by configuring App Insights during ConfigureServices
, but I'm left a bit stumped as to how to configure Serilog without TelemetryConfiguration.Active
- is there a recommended way to do this?
Apologies if I've missed something in the documentation - I couldn't spot anything relevant to this.
Metadata
Metadata
Assignees
Labels
No labels