Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSON validation failed for IncludeScopes in appsettings.json

I'm using ASP.NET Core 2.1.

Why am I getting Expression must be of type object for IncludeScopes in my appsettings.json file?

enter image description here

Here's a simplified version of the JSON needed to show the warning. To reproduce this, you just need to create a blank ASP.NET Core project and update 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"
    }
  }
}
like image 894
David Klempfner Avatar asked Mar 29 '26 02:03

David Klempfner


1 Answers

As the github issue said, you add the IncludeScopes to the wrong level. Change like below:

{
  "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"
    }
  }
} 
like image 196
Rena Avatar answered Mar 31 '26 04:03

Rena



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!