Some general setup of my system:
- Windows x64
- .net 3.1
- AspNet.Core
- Serilog + AppInsights writer
Recently, we started to observe many trace logs like below. I think something went wrong when we try to write log into AppInsights. But we can see our logs. It seems we have everything we wanted logging into AppInsights correctly. But we also have this unwanted trace message logged in as well, and there are a lot of them.
This trace message happens on my local machine, in our Azure AKS environment. But the stack trace is too short to help locating the origin of the error.
AI (Internal): [Microsoft-ApplicationInsights-Core] [msg=Log Error];[msg=Exception while initializing Microsoft.ApplicationInsights.AspNetCore.TelemetryInitializers.ClientIpHeaderTelemetryInitializer, exception message - System.ObjectDisposedException: Request has finished and HttpContext disposed.
Object name: 'HttpContext'.
at Microsoft.AspNetCore.Http.DefaultHttpContext.ThrowContextDisposed()
at Microsoft.AspNetCore.Http.DefaultHttpContext.get_Features()
at Microsoft.ApplicationInsights.AspNetCore.TelemetryInitializers.TelemetryInitializerBase.Initialize(ITelemetry telemetry)
at Microsoft.ApplicationInsights.TelemetryClient.Initialize(ITelemetry telemetry)]