Version of NLog.dll in use: 1.0.0.505, NLog for .NET 2.0
config file settings: <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" throwExceptions="true"> <targets> <target name="file" xsi:type="File" layout="${longdate} ${message}" fileName="c:\ThruputLogs\log.txt" archiveFileName="c:/ThruputLogs/archive/log.#.txt" archiveEvery="Day" archiveNumbering="Rolling" maxArchiveFiles="5" concurrentWrites="true" keepFileOpen="false" encoding="iso-8859-2" createDirs="true" /> </targets> <rules> <logger name="*" minlevel="Debug" writeTo="file" /> </rules> Testing using C# code in simple EXE, running under my windows identity, I am an admin on the local machine: LogFactory lf = new LogFactory(); Logger lg = lf.GetCurrentClassLogger(); lg.Log(LogLevel.Info, @"Some Logging Test Message Text"); MessageBox.Show("Done"); When first running, if the log file "log.txt" in the target directory does not exist, it is created, and log messages are written to it. This works until the date changes. Once the date changes, I expect that the existing log will be placed into the archive directory with the name "log.0.txt", or "log.1.txt", etc., and a new log.txt file will be started with new date's messages. However, nothing is happening at all. The archive directory does not get created, no archive files are created, nothing gets written to any log file any longer and no exceptions are thrown. If I manually make a change in the existing log file so that it's last date modified now reads as the current date, the log messages start getting written to the file again, but still no archive. I would appreciate any thoughts or help anyone can provide on this. |
Administrator
|
Try changing your archiveFileName layout
From: archiveFileName="c:/ThruputLogs/archive/log.#.txt" To: archiveFileName="c:/ThruputLogs/archive/log.{#}.txt" Also - you might want to include a few more # to be safe. |
Is it mandatory to add {#} in archive file name ?
Because i have checked with " exception_${date:format=yyyyMMddHHmm}.log " and it is not working, but if i change above to " exception_${date:format=yyyyMMddHHmm}.{#}.log " it is working fine. So please guide me what i am missing.
Thanks,
Vijay |
|
Free forum by Nabble | Edit this page |