How to configure Logging without appsetting.json?

293 views Asked by At

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?

0

There are 0 answers