Datetime stamp for Rolling File Logger EntLib 3.0

Topics: Logging Application Block
Apr 11, 2007 at 3:23 AM
Hi,
I had a couple of questions regarding the RollingFlatFileTraceListener in Version 3 of the enterprise Library. First of all, if I don't want to specify a maximum roll over file size (i.e file can grow to any size, rollover happens based on time),I presume I specify 0 or -1 for the rollSizeKB parameter in the constructor?

The second and more important question is regarding the TimeStamp that will be appended to the roll over file. Basically, my question is do only the rollover files get time stamped or is there was a way to get the "original" file to be time stamped as well? Its just that if i come back in a week and look at the log directory. It would be nice to see a set of files "MyApp.11-Apr-2007.txt", "MyApp.12-Apr-2007.txt", "MyApp.13-Apr-2007.txt" etc. rather than one file called "MyApp.txt" and all the others called "MyApp.12-Apr-2007" etc.
Apr 18, 2007 at 1:15 AM
Anybody? Anyway to timestamp the orginal file as well instead of just the rolled over files?
May 14, 2007 at 1:46 PM

nyathancha wrote:
Anybody? Anyway to timestamp the orginal file as well instead of just the rolled over files?


dear I am using EntLib Jan 2006 for .NET 2.0 and wanna do the same thing and looking for help here, I want to use the rolling file appeneder but dont know how, I think I need to extened the library by my self.
May 14, 2007 at 4:19 PM
The RollSizeKB parameter is purely optional. If you just want your file to rollover each day then specify:

RollFileExistsBehavior = Increment
RollInterval = Day
RollSizeKB = 0 // Just Leave It the Default of 0 which means ignore.

As to why it doesn't include the date on the first file is beyond me :) The only solution I can think of at the moment is to change the source code. It appends the date during a rollover but obviously not at the beginning. Looks to me like you could easily just call the ComputeArchiveFileName Method at the beginning to get the first file to be named with the date.

Regards,

Dave

___________________________

David Hayden
Microsoft MVP C#
May 14, 2007 at 4:23 PM
Enterprise Library 2.0 doesn't include the Rolling Log File.

However, I have had success with Erywn's Rolling Log File for Ent Lib 2.0:

http://bloggingabout.net/blogs/erwyn/articles/rolling_file_trace_listener.aspx

Regards,

Dave

_____________________________

David Hayden
Microsoft MVP C#