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

时间:2018-08-29 07:45:35

标签: c# asp.net-core .net-core asp.net-core-2.1

这是我的配置文件:

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

我用来加载配置文件的这段代码:

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

但是它为类别InformationSystemMicrosoft的类别设置了Debug日志级别。我在哪里弄错了?

1 个答案:

答案 0 :(得分:1)

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

相关问题