我的C#程序有以下的NLog.config配置文件:
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log">
<targets>
<target xsi:type="File" name="file1" fileName="file1.log" layout="${message}" />
<target xsi:type="File" name="file2" fileName="file2.log" layout="${message}" />
<target xsi:type="File" name="file3" fileName="file3.log" layout="${message}" />
<target xsi:type="File" name="file4" fileName="file4.log" layout="${message}" />
<target xsi:type="File" name="file5" fileName="file5.log" layout="${message}" />
<target xsi:type="File" name="file6" fileName="file6.log" layout="${message}" />
</targets>
<rules>
<logger name="logger1" minlevel="Debug" writeTo="file1" />
</rules>
</nlog>
我的程序需要根据用户配置将消息记录到不同的日志文件集中,例如,有时写入“file1、file2”,有时写入“file2、file3、file4”。
那么,在运行时根据用户配置自定义“logger1”中的“writeTo”属性是否可能?
非常感谢。