alefranz / MELT

MELT is a free, open source, testing library for the .NET Standard Microsoft Extensions Logging library. It is a solution to easily test logs.
Apache License 2.0
74 stars 5 forks source link

FilterByMinimumLevel does not change logger.IsEnabled result #12

Open wxtsxt opened 4 years ago

wxtsxt commented 4 years ago

enabledInformation variable below should be false:

    var factory = MELTBuilder.CreateLoggerFactory(options =>
                options.FilterByMinimumLevel(LogLevel.Error));

            var logger = factory.CreateLogger<object>();
            var enabledInformation = logger.IsEnabled(LogLevel.Information);
alefranz commented 4 years ago

Hello!

Currently the filter in the options only control what is captured in the sink, it doesn't change the configuration of the logger. That it means is that your application would still behave like if the logger is enabled but then that entry will not be captured in the sink.

I agree this is a bit confusing. I'm currently refactoring the library to use the built-in LoggerFactory and I am then considering removing this internal capability of filtering message and rely on the built-in options to do the filtering, see #10