2014-11-05 11 views
5

Gibt es eine Möglichkeit NLog.config Informationen in meine app.config Datei zu legen? Auf diese Weise kann ich eine Konfigurationsdatei statt zwei haben. Es könnte so aussehen:Gibt es eine Möglichkeit NLog.config Informationen in meine app.config Datei zu legen?

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <configSections> 
    <section name="nlog" type="..." /> 
    </configSections> 
    <nlog> 
    <targets>...</targets> 
    <rules>...</rules> 
    </nlog> 
</configuration> 

Bitte lassen Sie mich wissen, wenn dies ein Duplikat ist.

+2

Es ist richtig in der Dokumentation: '' https://github.com/nlog/NLog/wiki/Configuration-file# Konfigurationsdatei-Standorte – nemesv

+0

@nemesv, das ist genau das, was ich wollte. Vielen Dank. – user2023861

Antwort

10

Natürlich können Sie die Konfiguration in Ihre app.config-Datei einfügen.

Sie müssen nur die NLog.Config.ConfigSectionHandler so verwenden Sie

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <configSections> 
    <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/> 
    </configSections> 
    <nlog> 
    <targets>...</targets> 
    <rules>...</rules> 
    </nlog> 
</configuration> 

schreiben müssen, wie in der NLog documentation im Configuration file format Abschnitt beschrieben.