microsoft / ApplicationInsights-dotnet-logging

.NET Logging adaptors
106 stars 49 forks source link

Can't use filter for ApplicationInsightsLoggerProvider #252

Closed OskarKlintrot closed 5 years ago

OskarKlintrot commented 5 years ago

I try to get only LogLevel.Information to get sent to Application Insight when using ILogger. I've tried to use create a filter but it doesn't seem to do anything (everything below Information gets logged as well):

This is what I'm trying to get working:

logBuilder.AddFilter<ApplicationInsightsLoggerProvider>(null, LogLevel.Information);

This is what I've used to be able to set a breakpoint and make sure the filter actually is getting used, which it is:

logBuilder.AddFilter<ApplicationInsightsLoggerProvider>(logLevel =>
{
    return logLevel >= LogLevel.Information; // Breakpoint here, seems to be working just fine
});

Is there any way to set the log level for what is being logged to Application Insights or is this a bug (or maybe by design)?

I'm trying to get everything up and running on .NET Framework 4.6.1 and not on dotnet core, if that matters.

OskarKlintrot commented 5 years ago

Sorry, I just realized that I'm using logBuilder.AddDebug() so it's probably the TraceListener that is logging stuff.