Description
I updated the Serilog.Sinks.ApplicationInsights nuget package from version 3.1.0 to 4.1.0 in my ASP.NET Core 6 app. When I start the app (console or web app), the app crashes during startup with a NullReferenceException. This exception doesn't contains any information why this happend.
I investigate my app Serilog setup in Startup.cs and found out, Serilog.Sinks.ApplicationInsights required the AI connection string and no longer the instrumentation key. But my config had still the instrumentation key only.
Microsoft itself reports code warnings to use connection string instead instrumation key. But the app is will work, when I don't do that.
ReproductionThe Serilog config in Startup.cs like before. Add this to your appsettings.json { "Serilog": { "Using": [ "Serilog.Sinks.ApplicationInsights" ], "WriteTo": [ { "Name": "ApplicationInsights", "Args": { "instrumentationKey": "#{ApplicationInsightKey}#", "outputTemplate": "[{Timestamp:HH:mm:ss} {Level:u3} {Application}] {Message:lj} {NewLine}{Exception}", "telemetryConverter": "Serilog.Sinks.ApplicationInsights.Sinks.ApplicationInsights.TelemetryConverters.TraceTelemetryConverter, Serilog.Sinks.ApplicationInsights", "restrictedToMinimumLevel": "Warning" } } ] } }
Expected behavior
If a downwards compatibility is impossible, then should Serilog.Sinks.ApplicationInsights throw an human readable ConfigurationException or ArgumentException. e.g "The Application Insights configuration string was not set."
Relevant package, tooling and runtime versions
NET 6
ASP.NET Core Web app and Console app
Serilog.AspNetCore 6.0.1
Serilog.Extensions.Hosting 5.0.1
Serilog.Extensions.Logging 3.1.0
Serilog.Settings.Configuration 3.3.0
Serilog.Sinks.ApplicationInsights 4.0.0
Serilog.Sinks.Console 4.1.0
Additional context
Add any other context about the problem here.
Description I updated the Serilog.Sinks.ApplicationInsights nuget package from version 3.1.0 to 4.1.0 in my ASP.NET Core 6 app. When I start the app (console or web app), the app crashes during startup with a NullReferenceException. This exception doesn't contains any information why this happend.
I investigate my app Serilog setup in Startup.cs and found out, Serilog.Sinks.ApplicationInsights required the AI connection string and no longer the instrumentation key. But my config had still the instrumentation key only. Microsoft itself reports code warnings to use connection string instead instrumation key. But the app is will work, when I don't do that.
Reproduction
The Serilog config in Startup.cs like before. Add this to your appsettings.json { "Serilog": { "Using": [ "Serilog.Sinks.ApplicationInsights" ], "WriteTo": [ { "Name": "ApplicationInsights", "Args": { "instrumentationKey": "#{ApplicationInsightKey}#", "outputTemplate": "[{Timestamp:HH:mm:ss} {Level:u3} {Application}] {Message:lj} {NewLine}{Exception}", "telemetryConverter": "Serilog.Sinks.ApplicationInsights.Sinks.ApplicationInsights.TelemetryConverters.TraceTelemetryConverter, Serilog.Sinks.ApplicationInsights", "restrictedToMinimumLevel": "Warning" } } ] } }
Expected behavior If a downwards compatibility is impossible, then should Serilog.Sinks.ApplicationInsights throw an human readable ConfigurationException or ArgumentException. e.g "The Application Insights configuration string was not set."
Relevant package, tooling and runtime versions
Additional context Add any other context about the problem here.