5

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

wageoghe
  • 27,390
  • 13
  • 88
  • 116
Delashmate
  • 2,344
  • 5
  • 26
  • 40

2 Answers2

6

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. 

Community
  • 1
  • 1
wageoghe
  • 27,390
  • 13
  • 88
  • 116
  • 1
    I've used log4net multiple times specifically because of its rollover capability. Easy to configure & I've had no problems. If it could roll over on date *and* limit number of files it'd be perfect! – rich p Apr 29 '15 at 15:03
1

I also have been faced with the both issues (filesize -rollover and Timestamps non UTC for events) of the standard implementation of TraceListener and I didn't want to have a third party tool.

I found this solution which comes with minimum effort:

http://www.geekzilla.co.uk/View2C5161FE-783B-4AB7-90EF-C249CB291746.htm

Daniel
  • 191
  • 1
  • 5