2

I have the following in the appsettings.json (.net core asp.net project):

{
  "Serilog": {
    "WriteTo": [
      { "Name": "File", "Args": { "path": "sample.txt" } },
      { "Name": "Debug" }
    ]
  }
}

In production, I want to remove the { "Name": "Debug" } portion, so I have the same thing except for the debug portion in appsettings.Production.json:

{
  "Serilog": {
    "WriteTo": [
      { "Name": "File", "Args": { "path": "sample.txt" } },
    ]
  }
}  

However, the keys seem to be additive, so the Debug portion is not removed. The keys resolve to serialized values and thus I don't see how they would be removed.

Does appsettings architecture allow for removal of nodes? If so, how?

AngryHacker
  • 59,598
  • 102
  • 325
  • 594
  • 2
    I think that might defeat the purpose of having an appsettings.json file. If we wanted to specify in our code what the values should be then we wouldn't need the file. The point of the file is that we can have different versions of the file for different environments. – Scott Hannen Jun 17 '19 at 17:57
  • 1
    Can you add additional appsettings.Development.json which will include the specific "Debug" section? I believe by doing so you can separate the shared appsettings.json from non-common configurations. – mexanichp Jun 17 '19 at 18:07
  • @mexanich That's what I ended up doing. I was thinking back to web.config based configurations which did allow you to remove things. I thought appsettings has the same feature and I just couldn't find it. – AngryHacker Jun 17 '19 at 18:26

0 Answers0