3
我有一個winForm應用程序。我正在使用NLog進行記錄。我的配置文件如下。我可以在運行時在用戶定義的這個配置文件中設置任何參數。例如對於archiveAboveSize="4000"
我可以在winform中有一個numericupdown,它可以從用戶輸入這個值(所以4000可以是3000或5000),然後相應地在配置文件中設置這個值?使NLog配置文件用戶在運行時定義
<?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">
<targets>
<target xsi:type="File"
name="file"
layout="${longdate}|${level:uppercase=true}|${logger}|${message}"
archiveAboveSize="4000"
maxArchiveFiles="1"
archiveFileName="${basedir}/log_archived.txt"
fileName="log.txt" />
</targets>
<rules>
<logger name="*" minlevel="Info" writeTo="file" />
</rules>
</nlog>
您的意思是沒有辦法在運行時更新NLog配置文件。例如從numericupdown值? – user2968369
嗯有趣..我從來沒有與LINQ合作過。如果我只是在添加System.Xml.Linq namesapace後將此代碼粘貼到我的項目中,它應該可以工作嗎? – user2968369
因爲我越來越'var fileTarget = ....'null – user2968369