Cannot get archive by month working

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Cannot get archive by month working

wade.martin
I set up Nlog to archive on a monthly basis but when I change the clock (7/31/2011 to 8/1/2011) on the test machine and re-run my test it just writes the 8/1 log file and does not archive the 7/31 file.

Any suggestions would be appreciated.

Nlog.config

<target name="AuditLogger" xsi:type="File"
        layout="${longdate} ${level} ${event-context:eventId} ${message} ${exception:format=tostring}"
        fileName="c:\audit\radiator.web.audit.${shortdate}.log.txt"
        archiveFileName="c:\archive\${shortdate}.archive.log.txt"
        archiveEvery="Month"
        archiveNumbering="Rolling"
        maxArchiveFiles="12"
        concurrentWrites="true"
        createDirs="true"
        keepFileOpen="false"
        encoding="iso-8859-2" />
Reply | Threaded
Open this post in threaded view
|

Re: Cannot get archive by month working

Jason LaFlair
Administrator
Take a look at this previous post:

http://nlog-forum.1685105.n2.nabble.com/Archiving-problem-td1685676.html#a6475603

this should help explain.
Reply | Threaded
Open this post in threaded view
|

Re: Cannot get archive by month working

wade.martin
No luck with that solution.
I changed the config (see below) but now it just writes to the same log file (radiator.web.log.txt) each time. Does anyone know how nLog determines when to archive? Do it 'scan' the directory for old files or does it parse the existing log file to determine if an archive operation is needed?

layout="${longdate} ${level} ${logger} ${event-context:eventId} ${message} ${exception:format=tostring}"
        fileName="C:\logs\radiator.web.log.txt"
        archiveFileName="c:\archive\{#}.archive.log.txt"
        archiveEvery="Month"
        archiveNumbering="Rolling"
        maxArchiveFiles="12"
        concurrentWrites="true"
        keepFileOpen="false"
        createDirs="true"
        encoding="iso-8859-2" />
Reply | Threaded
Open this post in threaded view
|

Re: Cannot get archive by month working

Jarek Kowalski
Administrator
In reply to this post by wade.martin
This is because you're already including ${shortdate} in your log file
name. You need to remove that.

Jarek
NLog Blog