Rolling File Trace Listner

Topics: Logging Application Block
Feb 27, 2007 at 1:48 PM
I realize this is a cross post and not officially part of the EL code, but hoping someone else has worked with this and might have insight.

With limited documentation on the RollingFile I have questions on how the log files are supposed to operate. I threw together a simple app to test this functionality but have some surprising results. I configured the app.config to use Filename RollingTraceLog0.log with a simple Text Formatter. I wanted the files to roll over once they got to 1MB in size and I wanted to keep 3 files for history purposes. When first testing, my logs went into the RollingTraceLog0.log file until this filled up, then it appeared after 1 MB to copy the results to a new file name RollingTraceLog0Tue, 13 Feb 2007 20.58.51 GMT.633071758207172144.log, followed by the next roll over of RollingTraceLog0Thu, 15 Feb 2007 22.40.31 GMT.633071761246522420.log. At this point I expected the rolling to stop but the next time I hit 1 MB I got a 4th file with similar name to the last two. This doesn't seam correct to me. Am I missing something? I also don't see any way to format the file names when they are rolled over. Is this an option that I am missing somewhere?

So at this point I continued on to push the limits of this code to see what it would do. The next time I hit the 1MB file limit, my most recent file appeared to be deleted and a newer filename was created in its place and populated. Is there no successive rollover in this code where the oldest log file is deleted and a new log file is created? I can't see the use of keeping around the original two rolled over log files but then only modify the most recent one. Please explain.

Feb 27, 2007 at 4:03 PM
As an FYI, there is a Rolling Flat File TraceListener that is being added to Enterprise Library 3.0.

It is not complete in the current January 2007 release, but I expect it to be complete in the February 2007 release which I am hoping will be available for download this week.

You may want to peek at it when the Feb 2007 EntLib is released.




David Hayden
Microsoft MVP C#