Closed nhart12 closed 5 years ago
Thanks for reporting! Sorry for the bad state of docs.
You are right - flush() is not done automatically. Please see the workaround here: https://stackoverflow.com/questions/55289534/why-is-ilogger-not-logging-to-azure-app-insights/55290922#55290922
docs are being updated to use new example with flush. Once that is done, we'll fix the product itself.
@cijothomas this workaround seems to stop working in later releases of Microsoft.ApplicationInisghts 2.10 +
@nhart12 Did you mean 2.10.0-beta4 which was just released? I'll check this, but if you have more information, please do share.
@cijothomas actually I was wrong, I believe it's the update from Microsoft.Applications.AspNetCore from 2.6.1 > 2.7.0-beta3 that made the logging stop working. I'm still digging into it on my end.
Actually after some digging, I believe in 2.7 I no longer need the loggingBuilder.AddApplicationInsights("my-key"); call and it is default filtering my information logs. I think I have it working again. Do you know if the flush is still required in 2.7-beta3? Edit: Yes it's still needed
Ok. in 2.7.0-beta3 onwards, ilogger is automatically captured.
Flush is only needed for console apps where app is exiting, and there are still items pending in buffer..
Closing in favor of https://github.com/microsoft/ApplicationInsights-dotnet-logging/issues/284
With a console application on dotnet core 2.2 I'm finding not all events are making it to AI. Here is a simple repro project where log is not sent :
And the Program.cs (Note I'm even disposing of the ServiceProvider.)
If I fork this library and add a telemetryClient.Flush() then my log is sent (only if I dispose the ServiceProvider). Line 108 here: https://github.com/Microsoft/ApplicationInsights-dotnet-logging/blob/develop/src/ILogger/ApplicationInsightsLoggerProvider.cs