ApplicationInsights-dotnet icon indicating copy to clipboard operation
ApplicationInsights-dotnet copied to clipboard

Show that ApplicationInsightsLoggerProvider defaults to Warning only if there is no config

Open mikeblakeuk opened this issue 3 years ago • 7 comments

https://github.com/microsoft/ApplicationInsights-dotnet/blob/405fd6a9916956f2233520c8ab66110a1f9dcfbc/examples/ConsoleApp/Program.cs#L49

show that logger.LogInformation("not logged");

mikeblakeuk avatar Jun 14 '22 15:06 mikeblakeuk

Not sure what exactly you meant. There is no defaults by ApplicationInsightsLoggerProvider in a console app. Whatever is the configuration for the application, is applied to ApplicationInsightsLoggerProvider, just like any other provider.

cijothomas avatar Jun 15 '22 16:06 cijothomas

If you don't have a config, and try to logger.LogInfo, it won't log to App insights.

This is due to https://github.com/microsoft/ApplicationInsights-dotnet/blob/main/NETCORE/src/Shared/Extensions/ApplicationInsightsExtensions.cs#L427

mikeblakeuk avatar Jun 16 '22 10:06 mikeblakeuk

Thanks for clarifying. Its already covered in the docs : https://docs.microsoft.com/en-us/azure/azure-monitor/app/worker-service , but would be nice to mention in the examples in this repo too.

cijothomas avatar Jun 16 '22 14:06 cijothomas

Thanks for clarifying. Its already covered in the docs

To be more specific. It is documented here: https://learn.microsoft.com/en-us/azure/azure-monitor/app/worker-service#ilogger-logs and in the C# log warning example lines.

logger.LogWarning("A sample warning message. By default, logs with severity Warning or higher is captured by Application Insights");

LockTar avatar Nov 16 '22 09:11 LockTar

It would be nice if there was a line under it logger.LogInformation("Lower than Warning is not logged if detaults are used"); to help developers who get the sample, add info logs and then look for them.

mikeblakeuk avatar Nov 16 '22 12:11 mikeblakeuk

This issue is stale because it has been open 300 days with no activity. Remove stale label or this will be closed in 7 days. Commenting will instruct the bot to automatically remove the label.

github-actions[bot] avatar Sep 13 '23 00:09 github-actions[bot]

Could the Info be added?

mikeblakeuk avatar Sep 15 '23 07:09 mikeblakeuk