JSON appsettings.json 中的 IncludeScopes 验证失败

JSON validation failed for IncludeScopes in appsettings.json

我正在使用 ASP.NET Core 2.1。

为什么我的 appsettings.json 文件中 IncludeScopes 得到 Expression must be of type object

这是显示警告所需的 JSON 的简化版本。 要重现这一点,您只需创建一个空白 ASP.NET 核心项目并更新 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"
    }
  }
}

the github issue所说,您将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"
    }
  }
}