I just wanted to post this here in case someone else runs into same issue as I did, and not lose a day or two trying to figure out what's happening. In case this should not be here feel free to close it
This is in particular bug with App insights and has nothing to do with serilog. The problem is when there are keyed services registered in DI (.net 8 feature) TelemetryConfiguration won't be registered and if you are using something like this
Log.Logger = new LoggerConfiguration()
.WriteTo.ApplicationInsights(
serviceProvider.GetRequiredService<TelemetryConfiguration>(),
TelemetryConverter.Traces)
.CreateLogger();
to configure serilog it will throw an exception
System.InvalidOperationException: 'No service for type 'Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration' has been registered.
Hello,
I just wanted to post this here in case someone else runs into same issue as I did, and not lose a day or two trying to figure out what's happening. In case this should not be here feel free to close it
This is in particular bug with App insights and has nothing to do with serilog. The problem is when there are keyed services registered in DI (.net 8 feature) TelemetryConfiguration won't be registered and if you are using something like this
to configure serilog it will throw an exception
System.InvalidOperationException: 'No service for type 'Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration' has been registered.
you can find more information here
I can see that for some people workaround was to register App insight before any other services.
I've experienced this issue with following versions: Serilog.Sinks.ApplicationInsights - 4.0.0 Serilog.AspNetCore - 8.0.2