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";
logEntry.Categories.Add("General");

Logger.Write(logEntry);

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?

Thanks,
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.

Regards,

Dave

_____________________________

David Hayden
Microsoft MVP C#
http://www.davidhayden.com/
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.

HTH
Tom
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.

Chris
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: http://blogs.msdn.com/tomholl/archive/2006/01/22/516055.aspx.

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

Chris