RollingFlatFileTraceListener does not work?

Topics: Logging Application Block
Jan 24, 2007 at 4:59 PM
Hi, I configured General Logging Policy to have Rolling Flat File Trace Listener. I did not change any property of listener, I used default. When I write logEntry like this
//Insert log
LogEntry logEntry = new LogEntry();
logEntry.EventId = 1;
logEntry.Priority = 1;
logEntry.Severity = System.Diagnostics.TraceEventType.Information;
logEntry.Message = "Write something";


TraceListener creates rolling.log file but it is empty. If I add old Flat File Trace Listener it works ok.

Is this known bug or what, please help because I need answer?

Indigo Cowboy
Jan 24, 2007 at 6:41 PM
It may be a bug.

If you notice, the Rolling Flat File Trace Listener does not have a property to specify a Formatter to format output messages. I would expect one so we could specify the format of the messages to be added to the file.

I also tried using the rolling flat file tracelistener in a really basic scenario, and it did not log anything. This may be due to the fact that a Formatter can't and hasn't been assigned to the tracelistener.

It may have been an oversight and we may have to wait until the next drop before getting a fix.




David Hayden
Microsoft MVP C#
Jan 24, 2007 at 7:31 PM
Yep there are a few bugs in this first drop of this Trace Listener, but we're working on them!

Thanks for reporting this issue. We took a look and it is probably caused by the Trace Listener not being flushed - if you write several events then it should (eventually) write to the file. A workaround for now will be to explicitly call Logger.Writer.Dispose() when you're done, which should result in all of the Trace Listeners being flushed and disposed.

Jan 24, 2007 at 7:36 PM
I really hope we get a formatter for the RollingFlatFileTraceListener. Without it, unfortunately we can't use it and have to revert back to the regular flatfile approach.

Another option that we'd like to see is a setting for the maximum number of files to keep. For example, I set the RollingFlatFileTraceListener to roll a new file every day, but I only want the last 7 days of logs.

Jan 24, 2007 at 8:23 PM
Formatter support is definitely coming!
Jan 25, 2007 at 12:03 AM
Thanks Tom....

Looking at the source code, it looks like we can specify local time using a token like "Timestamp local: {timestamp(local)}" which you describe in your blog here:

So we don't need to make any source edits to get local time in EL3, right?