Home > OS >  NLog not working if I move NLog.config to a subfolder
NLog not working if I move NLog.config to a subfolder

Time:07-20

So I want to organize my project and I've made a subfolder with all my configuration files. I've noticed that when I move NLog.config to this subfolder it wont work. Has anybody noticed this behaviour? I'd like to learn why it worked like that.

CodePudding user response:

As by this github thread, this should work if you put it in you app.config:

<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" autoReload="true">
    <include file="Config\NLog.config"/>
</nlog>

As mentioned by comment, you need to include the nlog section as well, here's the full snippet:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <configSections>
        <sectionGroup name="common">
            <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
        </sectionGroup>
        <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
    </configSections>

    <common>
        <logging>
            <factoryAdapter type="Common.Logging.NLog.NLogLoggerFactoryAdapter, Common.Logging.NLog32">
                <arg key="configType" value="INLINE" />
            </factoryAdapter>
        </logging>
    </common>

    <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" autoReload="true">
        <include file="Config\NLog.config"/>
    </nlog>
</configuration>

source: github thread

  • Related