I have an Azure Function that uses Serilog to write to AppInsights with Serilog AppInsights sink v3.1.
The code in Startup.cs
looks like this
Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(config)
.CreateLogger();
and appsettings.json
"Serilog": {
"Using": [
"Serilog.Sinks.ApplicationInsights"
],
"WriteTo": [
{
"Name": "ApplicationInsights",
"Args": {
"instrumentationKey": "...",
"restrictedToMinimumLevel": "Verbose",
"telemetryConverter": "Serilog.Sinks.ApplicationInsights.Sinks.ApplicationInsights.TelemetryConverters.TraceTelemetryConverter, Serilog.Sinks.ApplicationInsights"
}
}
],
...
It can happily write application logs into AppInsights.
The latest Github documentation mentioned the deprecation of telemetry configuration active and future removal support of Instrumentation Key therefore I would like to upgrade the library to version 4.0.
However, when I upgrade to the sink to v4.0, I get this exception:
Please help.
So I just spent a good chunk of time debugging this, because I also ran into the issue. I'll admit I should have look at the git log for the app insights sink, because the offending commit is right here
They adjusted their namespaces, which causes the Serilog Configuration binding not to be able to find the type Serilog.Sinks.ApplicationInsights.Sinks.ApplicationInsights.TelemetryConverters.TraceTelemetryConverter
anymore. Instead the namespace is Serilog.Sinks.ApplicationInsights.TelemetryConverters.TraceTelemetryConverter
as shown in the commit I linked.
Hope this helps