为什么我不能通过配置文件更改日志类别的日志级别?
Why i can't to change log level for logging categories by config file?
这是我的配置文件:
{
"Logging": {
"LogLevel": {
"Console": "Critical",
"Default": "Warning",
"System": "Warning",
"Microsoft": "Trace"
}
}
}
我用来加载配置文件的代码:
hostBuilder.ConfigureLogging ( ( context, builder ) =>
{
builder.AddConfiguration ( context.Configuration.GetSection ( "Logging" ) );
builder.AddConsole ( );
} );
但它为以下类别设置了 Information
日志级别:System
、Microsoft
和 Debug
Default
。我哪里弄错了?
我发现了一个错误。有两个配置文件 appsettings.json 和 appsettings.Development.json。并且系统在开发模式下使用它。
这是我的配置文件:
{
"Logging": {
"LogLevel": {
"Console": "Critical",
"Default": "Warning",
"System": "Warning",
"Microsoft": "Trace"
}
}
}
我用来加载配置文件的代码:
hostBuilder.ConfigureLogging ( ( context, builder ) =>
{
builder.AddConfiguration ( context.Configuration.GetSection ( "Logging" ) );
builder.AddConsole ( );
} );
但它为以下类别设置了 Information
日志级别:System
、Microsoft
和 Debug
Default
。我哪里弄错了?
我发现了一个错误。有两个配置文件 appsettings.json 和 appsettings.Development.json。并且系统在开发模式下使用它。