I have been trying to get my logging working so that I can maintain a 2 week archive of daily logs.
From looking at the official documentation and this question, I have added the following to my NLog.config file target
<target name="file"
xsi:type="File"
fileName="${basedir}/../logs/${shortdate}.log"
archiveFileName="${basedir}/../logs/archive/archive.${shortdate}.{#}.txt"
archiveEvery="Day"
archiveNumbering="Rolling"
maxArchiveFiles="14" />
My understanding is that this should on detection of a new day, create the archive.${shortdate}.{#}.txt
file in the archive folder.
What I am actually seeing is that a new log file is generated for each day which is expected, but the archiving is never occurring.
Am I configuring this wrongly, or is there something different you need to do to get this to work with NLog 2.0.1
Note that I am testing this my just manually changing my computer's date settings, although I have had it running over night once and still nothing was archived.
Edit: I have been able to get some archiving working if I change the target to archive based on file size like so:
<target name="file"
xsi:type="File"
fileName="${basedir}/../logs/${shortdate}.log"
archiveFileName="${basedir}/../logs/archive/archive.${shortdate}.{#}.txt"
archiveAboveSize="51200"
archiveNumbering="Rolling"
maxArchiveFiles="14" />
So just seems to be something wrong in the day archiving