trace listener - log file size & reset log file content

  • Thread starter Thread starter Bandu
  • Start date Start date
B

Bandu

Hi,

I'm trying to write trace out using TextWriterTraceListener. It work
fine. But I would like to do the following 2 tasks but I can't find
any way to do it.

- Limit maximum log file size
- Refresh log file content everytime program start.

thank you very much,

Bandu
 
Bandu said:
Hi,

I'm trying to write trace out using TextWriterTraceListener. It work
fine. But I would like to do the following 2 tasks but I can't find
any way to do it.

- Limit maximum log file size
- Refresh log file content everytime program start.

To accomplish the first, you'll need to create your own TraceListener
sub-class (perhaps inheriting TextWriter, depending on specifics),
monitoring the output log file size and restricting the size as
appropriate to your needs.

I don't really understand the second, not without a concise-but-complete
code example from you demonstrating exactly what you're doing. Seems to
me that if you just delete the previous output file when your program
starts, that would accomplish what you're asking for.

Pete
 
Greetings,

I believe what you're referring to is known as a "rolling" log. Where the
top (most recent) N number of entries are maintained between program
executions, and older entries are dropped in the interest of file size.

If this is the case, you can find some helpful examples and open source
solutions here:
http://csharp-source.net/open-source/logging

Google will turn up more possibilities, there are a lot of these types of
libraries available for .Net. I've also build my own before to address my
particular needs, it's not too difficult.

Hope this helps,
 
To accomplish the first, you'll need to create your own TraceListener
sub-class (perhaps inheriting TextWriter, depending on specifics),
monitoring the output log file size and restricting the size as
appropriate to your needs.

I don't really understand the second, not without a concise-but-complete
code example from you demonstrating exactly what you're doing.  Seems to
me that if you just delete the previous output file when your program
starts, that would accomplish what you're asking for.

Pete

thanks Pete.
 
Greetings,

I believe what you're referring to is known as a "rolling" log.  Where the
top (most recent) N number of entries are maintained between program
executions, and older entries are dropped in the interest of file size.

If this is the case, you can find some helpful examples and open source
solutions here:http://csharp-source.net/open-source/logging

Google will turn up more possibilities, there are a lot of these types of
libraries available for .Net.  I've also build my own before to addressmy
particular needs, it's not too difficult.

Hope this helps,
--
Roger Frost
"It's all about finding the correct solution. The solution exists,
this is just software :) There are no non-solutions." -Anthony Nystrom










- Show quoted text -

thanks Roger.
 
Back
Top