'NLog environment variable config files
I'm stuck on this kinda simple problem. I'm trying to make multiple nlog config files, so that nlog can load them depending on environment variable.
I've added nlog.debug.config, nlog.production.config, and changed ASPNETCORE_ENVIRONMENT to corresponding value, but no luck so far. I guess it's not that simple. I could set it up inside Startup.cs file, like this:
env.ConfigureNLog("nlog.environment.config");
But is there some automatic way?
Solution 1:[1]
The accepted answer is good, but NLog provides a standard way to do this as well. The .NET Core appsettings.json file is already environment specific, and you can configure NLog within these files.
For example, in appsettings.Staging.json you could have one "NLog" element and a different setting in appsettings.Production.json.
Here is the documentation.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
