appsettings.json 中 IncludeScopes 的 JSON 验证失败

Bac*_*ave 9 logging asp.net-core asp.net-core-2.1

我正在使用 ASP.NET Core 2.1。

为什么我的档案里会出现Expression must be of type object这样的情况?IncludeScopesappsettings.json

在此输入图像描述

下面是显示警告所需的 JSON 的简化版本。要重现此情况,您只需创建一个空白的 ASP.NET Core 项目并更新 appsettings.json:

{
  "Logging": {
    "IncludeScopes": false,
    "Debug": {
      "LogLevel": {
        "Default": "Warning"
      }
    },
    "Console": {
      "LogLevel": {
        "Default": "Warning"
      }
    }
  },
  "serilog": {
    "write-to": {
      "sumologic.url": "http://localhost",
      "RollingFile.pathFormat": "R\\Document\\API\\Logs-{Date}.log"
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

Ren*_*ena 12

正如github 问题所述,您将其添加IncludeScopes到了错误的级别。更改如下:

{
  "Logging": {
    "Console": {
      "LogLevel": {
        "Default": "Warning"
      },
      "IncludeScopes": false
    },
    "Debug": {
      "LogLevel": {
        "Default": "Warning"
      }
    }
    
  },
  "serilog": {
    "write-to": {
      "sumologic.url": "http://localhost",
      "RollingFile.pathFormat": "R\\Document\\API\\Logs-{Date}.log"
    }
  }
} 
Run Code Online (Sandbox Code Playgroud)