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
https://github.com/serilog-contrib/serilog-sinks-applicationinsights/commit/8e4e26a8fdfa12da6ed15afcc94889e5f399ff97#diff-bc9f0e00aaa0aef88484faa764a62f13d26f07bf6c2b6df21cd8d893aa47c2e0
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With