Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set the rollover strategy in System.Diagnostics trace log

I have a project, that using System.Diagnostics for logging,

And it creating lots of new logs files, each one starting with GUID,

Even when the last log file was very small

I want to setup a role that controls the creation of new log file

Where can I configure it?

And second question: Where can I set the log to write non utc time?

Thanks

like image 805
Delashmate Avatar asked Sep 25 '11 11:09

Delashmate


1 Answers

See the following link for a discussion about rollover trace listeners:

What the best rollover log file tracelistener for .NET

The accepted answer recommends the FileLogTraceListener:

http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.logging.filelogtracelistener.aspx

I would encourage you to also look at Ukadc.Diagnostics as a way to add flexibility (and formatting) to System.Diagnostics tracing/logging:

http://ukadcdiagnostics.codeplex.com/

To answer your final question about logging in something other than UTC, I think the only answer is to write your own TraceListener (or use someone else's, such as Ukadc.Diagnostics). 

It goes without saying that logging frameworks like NLog and log4net are very popular for a reason:  they provide extremely powerful and flexible logging solutions, allowing you to focus on your application's functionality, not on solving logging problems. 

like image 99
wageoghe Avatar answered Oct 01 '22 11:10

wageoghe