简体   繁体   中英

NLog not working if I move NLog.config to a subfolder

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM