Closed qrli closed 5 years ago
Can you share the full registration code?
var builder = WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseConfiguration(new ConfigurationBuilder().AddCommandLine(args).Build())
.UseShutdownTimeout(TimeSpan.FromSeconds(30))
.UseApplicationInsights()
.ConfigureLogging((hostingContext, logging) =>
{
logging.AddApplicationInsights();
logging.AddFilter<ApplicationInsightsLoggerProvider>("Microsoft", LogLevel.Warning);
logging.AddFilter<ApplicationInsightsLoggerProvider>("System", LogLevel.Warning);
})
.NET Core SDK version: 2.1.403
Ah I found the cause. My logging settings are from the ASP.NET Core 1.x days, while 2.0 slightly changed the structure. After fixing that, it works fine.
Another issue misled me is that Visual Studio Appliation Insights panel seems to always show more telemetry, also duplicated telemetry, than it actually sends when running outside.
You can close this. Sorry and thanks for your time. :-)
@qrli Debugging from Visual Studio does extra injection - you can set ASPNETCORE_PREVENTHOSTINGSTARTUP = true to disable this. Or if you are in one of the newer VS versions, you can disable this in setting also.
No matter how I change "Logging" settings in appsettings.json, it has no effect. Other logger providers work as expected though. It seems only adding the following code works.