Fog Creek Software
Discussion Board




Rolling Logs in log4net or log4j?

We need to configure log4net to create a new log file each time our Windows Forms application starts.  It seems like the RollingFileAppender should handle this, but I can't find an example that does this.  The examples I find are all the same, keeping 10 logs of up to 100k each.  Is there a way to configure log4net to create a new file each time the  application starts, keeping the most recent 3?  I'd also like to name the log files based on the start time.

We're using log4net 1.20-beta 8, which is a port of log4j, so if you know how to do it in either one, I'd like to hear about it.

Thanks,
Ted

Ted Graham
Friday, June 11, 2004

log4j has a DailyRollingFileAppender.  Has it not been ported to log4net, yet?

You could look at the DailyRollingFileAppender code and "roll" your own ;-)

Caffeinated
Friday, June 11, 2004

Did you have any problem getting log4net working initally? I have spent a little time trying to get it working in a Windows Forms application, so far without luck. Did you use the 1.1 binary that comes with the beta 8 release?

When I tried using it in the mode that looks for a config file with the same name as the exe + config, it deleted my config file at startup. Running the console sample app works fine.

Was there any gotcha that you overcame to get it working?

ICBW
Friday, June 11, 2004

Hi ICBW:

No problems on getting it to work with Windows Forms, but this is my third app to use log4net, so I may have had something tricky I setup 2 years ago when I started using it that I have forgotten.  My log4net.dll is version 1.2.0.30714. 

Ted

Ted Graham
Friday, June 11, 2004

Hoo boy. After KayJay's post about complex numbers and 3 dimensional spaces I though this would be something about logarithms and Microsoft's .Net solution to the 4th dimension. Moving on now...

Anony Coward
Friday, June 11, 2004

Hmmm. I'll try it again on Sunday.

ICBW
Saturday, June 12, 2004

*  Recent Topics

*  Fog Creek Home