Hello,
I have 2 use cases for archives that I would like to use. In both cases, the archives are created like I would like, but the excessive archive files are not deleted. Has anyone seen this problem and does anyone have a solution for it?
The 2 use cases are:
1. A log file that wraps on size only. Archives are saved with a name that contains a timestamp of the time the archive was created. In this case, if multiple archives are created within the resolution of the timestamp, the extra files in that time are deleted, but the older ones remain. For example, in my test case below, if 5 MainLog archives are created in a minute, the first 2 will be deleted, but the archive files from previous minutes remain. I would like to have the older files deleted.
2. A log file that uses a timestamp as part of its name. When the timestamp changes a new file is created and the old is left. This is not actually an archive, but I need the older files to be deleted.
The configuration file I am using is (note that this is a test file with much quicker wrap values than I plan to use):
<?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 name="MainLog" xsi:type="File"
fileName="${basedir}\Logs\Main.log"
archiveAboveSize="1000"
archiveFileName="${basedir}\Logs\Main - ${date:format=yyyy-MM-dd HHmm}-{#}.log"
maxArchiveFiles="3"
header="${longdate} Logging started"
footer="${longdate} Shutdown"
layout="${longdate} ${logger} ${level:uppercase=true:padding=-5} - ${message}"/>
<target name="log2" xsi:type="File"
fileName="${basedir}\Logs\log2 - ${date:format=yyyy-MM-dd HHmm}.log"
maxArchiveFiles="3"
header="${longdate} Logging started"
footer="${longdate} Shutdown"
layout="${longdate} ${logger} ${level:uppercase=true:padding=-5} - ${message}"/>
<target name="debug" xsi:type="Debugger"
layout="${logger} - ${message}"/>
</targets>
<rules>
<logger name="*" minlevel="Warn" writeTo="MainLog" />
<logger name="*2*" minlevel="Trace" writeTo="log2" />
</rules>
</nlog>
Thanks for any help.