为什么我不能通过配置文件更改日志记录类别的日志级别?

问题描述 投票:1回答:1

这是我的配置文件:

{
  "Logging": {
    "LogLevel": {
      "Console": "Critical",
      "Default": "Warning",
      "System": "Warning",
      "Microsoft": "Trace"
    }
  }
}

我用这个代码加载配置文件:

        hostBuilder.ConfigureLogging ( ( context, builder ) =>
        {
            builder.AddConfiguration ( context.Configuration.GetSection ( "Logging" ) );
            builder.AddConsole ( );
        } );

但它为类别设置了Information日志级别:SystemMicrosoftDebugDefault。我在哪里弄错了?

c# asp.net-core .net-core asp.net-core-2.1
1个回答
1
投票

我发现了一个错误。有两个配置文件appsettings.json和appsettings.Development.json。系统在开发模式下使用它。

© www.soinside.com 2019 - 2024. All rights reserved.