2014-11-05 38 views
5

有沒有辦法將NLog.config信息放入我的app.config文件中?這樣我可以有一個配置文件而不是兩個。它可能看起來像這樣:有沒有辦法將NLog.config信息放入我的app.config文件中?

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

請讓我知道這是否是重複的。

+2

這是正確的在文檔中:'

'https://github.com/nlog/NLog/wiki/Configuration-file#配置文件位置 – nemesv 2014-11-05 20:30:11

+0

@nemesv,這正是我想要的。謝謝。 – user2023861 2014-11-05 21:26:47

回答

10

當然,你可以把配置放在你的app.config文件中。

你只需要使用NLog.Config.ConfigSectionHandler所以你需要作爲Configuration file format節中的NLog documentation描述寫

<?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> 

相關問題