有没有办法将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>

如果这是副本,请告诉我。

当然,您可以将配置放在app.config文件中。

你只需要使用NLog.Config.ConfigSectionHandler,所以你需要写

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

如配置文件格式部分的NLog文档中所述。