0

I am working on .net framework 4.7.2 web API which doesn't have appsetting.json. I wonder where should I configure the below setting for Microsoft.Extension.Logging?

"Logging": {
    "LogLevel": {
        "Default": "Information",
        "Microsoft": "Warning",
        "Microsoft.Hosting.Lifetime": "Information"
}

and Bind it to LoggerFilterOption on Startup?

Below seems not to work:

LoggerFilterOptions options = new LoggerFilterOptions();
var config = UnityConfig.Container.Resolve<IConfiguration>();
config.GetSection("Logging").Bind(options);

I want to control MinLogLevel and Rules (LoggerFilterOption)through the web.config, Can that be achieved?

Dugnom
  • 342
  • 1
  • 5
  • 12
n1k1
  • 51
  • 6
  • I might be wrong, but isn't Microsoft.Extension.Logging part of .NET core, not framework? – Neil Apr 30 '22 at 21:39
  • @Neil..yeah but can't we add this package explicitly?...I checked the current LoggerFilterOptions value, MinLogLevel is coming as "Trace" but not sure how to reset it if appsetting.json is not present – n1k1 May 01 '22 at 04:18

0 Answers0