I am working on a ASP.Net web API 2 project and have configured nlog to write application logs to a database.
Since we have 4 environments (local, testing, staging, prod) I need to write logs to different databases.
So, in my web.config I have :
<configSections>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/>
</configSections>
Also, I have a Nlog.config file:
<?xml version="1.0" encoding="utf-8"?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target name="ExceptionLog" type="Database">
<connectionString>
// DbConnectionString
</connectionString>
<commandText>
// INSERT COMMAND
</commandText>
// Parameters
</target>
What I need is a different connection string for each environment. Or perhaps a bunch of files like NLog.Staging.config, NLog.Testing.config etc.
Please advise.