Nlog.config
<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="DEBUG" internalLogFile="temp
log-internal.log">
<variable name="LogLevel" value="DEBUG"/>
<variable name="brief" value="${longdate} | ${level} | ${logger} | ${message}"/>
<variable name="verbose" value="${longdate} | ${machinename} | ${processid} | ${processname} | ${level} | ${logger} | ${message}"/>
<variable name="logLifetime" value="3"/>
<targets >
<target name="Global" xsi:type="File" fileName="Logs/GlobalLog.txt" archiveNumbering="Date" enableArchiveFileCompression="true" archiveFileName="Archive/IPSlog.{#}.zip" archiveDateFormat="yyyy-MM-dd"
maxArchiveDays="${logLifetime}"
archiveEvery="Day" />
<target name="S42K" xsi:type="File" layout="${brief}" fileName="Logs/S42K.txt" archiveNumbering="Date" enableArchiveFileCompression="true" archiveFileName="Archive/S42K.{#}.zip" archiveDateFormat="yyyy-MM-dd"
maxArchiveDays="${logLifetime}"
archiveEvery="Day" />
<target name="ServerApp" xsi:type="File" archiveDateFormat="yyyy-MM-dd" archiveNumbering="Date" enableArchiveFileCompression="true" archiveFileName="Archive/IPSlog.{#}.zip" fileName="Logs/ServerApp.txt"
maxArchiveDays="${logLifetime}"
archiveEvery="Day" />
<target name="Color" xsi:type="ColoredConsole" />
<target name="S42KRawData" xsi:type="File" layout="${brief}" fileName="Logs/S42KRawData.txt" archiveNumbering="Date" enableArchiveFileCompression="true" archiveFileName="Archive/S42KRawData.{#}.zip" archiveDateFormat="yyyy-MM-dd"
maxArchiveDays="${logLifetime}"
archiveEvery="Day" />
<target name="Advancis" xsi:type="File" layout="${brief}" fileName="Logs/Advancis.txt" archiveNumbering="Date" enableArchiveFileCompression="true" archiveFileName="Archive/Advancis.{#}.zip" archiveDateFormat="yyyy-MM-dd"
maxArchiveDays="${logLifetime}"
archiveEvery="Day" />
</targets>
<rules>
<logger name="Global" minlevel="${LogLevel}" writeTo="Global,Color" />
<logger name="S42K" minlevel="${LogLevel}" writeTo="S42K,Color" />
<logger name="ServerApp" minlevel="${LogLevel}" writeTo="ServerApp,Color" ></logger>
<logger name="S42KRawData" minlevel="TRACE" writeTo="S42KRawData,Color" />
<logger name="Advancis" minlevel="${LogLevel}" writeTo="Advancis,Color" />
</rules>
</nlog>
code part when service started
LogManager.Configuration.Variables["logLifetime"] = SetingFromINIfile.Setting[settingIterator++].Parameter;//contains "1"
LogManager.ReconfigExistingLoggers();
but loggers doesn't reconfig and use 3 days by default
Some details:
- ReconfigExistingLoggers() invoked in a task
- LogManager.Configuration.Variables["logLifetime"] return 1 after changing
what is the problem?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…