简体   繁体   English

如何在NLog.config中使用machine.config设置

[英]How can I use machine.config settings in the NLog.config

Is it possible to use a machine.config setting inside the Nlog.config? 是否可以在Nlog.config中使用machine.config设置?

Example

       <nlog>
          ...
          <target name="database" xsi:type="Database" 
keepConnection="true" dbDatabase="xxx" 
dbHost="**MACHINE_CONFIG_SETTING**" 
commandType="StoredProcedure"  dbProvider="System.Data.SqlClient" dbUserName="**MACHINE_CONFIG_SETTING**"
 dbPassword="**MACHINE_CONFIG_SETTING**" 
  connectionString="**MACHINE_CONFIG_SETTING**"
          commandText="stored_proc">
    </nlog>

We have the dbhost name and dbUsername in the machine config so I don't really want to duplicate that information in the Nlog config. 我们在机器配置中有dbhost名称和dbUsername,所以我真的不想在Nlog配置中复制该信息。 I don't want to put the whole of the Nlog configuration in the machine config if I can help it. 如果我能帮忙的话,我不想把整个Nlog配置放在机器配置中。

Any help would be very much appreciated. 任何帮助将非常感谢。

This should be possible, but you can't overwrite it partly. 这应该是可能的,但你不能部分覆盖它。

You can also use <include file="${basedir}/${machinename}.config"/> for reuse, which is a bit more flexible. 您还可以使用<include file="${basedir}/${machinename}.config"/>进行重用,这样会更灵活一些。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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