Friday, May 18, 2012
 
The best way to analyze your logs! Minimize
 Log4Net Mail archive   

The Log4Net mailing list is a great source of information about using log4Net, in this forum we collect all the messages in the log4net user list and some selected threads from the developer list.

Subject: Question about RollingLogFileAppender
Prev Next
You are not authorized to post a reply.

Author Messages
Pranav Varia

06/04/2008 7:13 PM  

Currently I have RollingLogFileAppender configured to hold a max of 20 files PER HOUR as follows:
    <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
      <file value="c:\logs\MyService.log" />
      <appendToFile value="true" />
      <rollingStyle value="Composite" />
      <maxSizeRollBackups value="20" />
      <maximumFileSize value="100KB" />
      <datePattern value="yyyyMMdd-HH" />
        ....
    </appender>
This configuration keeps last 20 files FOR EACH HOUR and hence the number of files add up indefinitely over time.
Is there a way to configure a absolute max number of total files (without regards to the rolling intervals)? I am looking to setup log4net to basically keep a max of last X number of files at any given point in time in the year or years.
Regards
Pranav

Peter Drier

06/04/2008 7:56 PM  
Not built into the RollingLogFileAppender..  There may be a hook if you want to extend it..  You'd want to make sure your cleanup wasn't done in the logging thread though, else it will hold up your application processing (and possibly your gui thread)

We have a separate method within our apps that remove log files older than XX days every time the app is started..  You could do something similar by having a timer fire every hour giving you a point to do your cleanup..  And you'd probably want to sort by modified date, getting rid of the oldest ones.. parsing the file names to determine the same would probably be annoying. 

I'm not going to ask why 20 x 100kb files per hour though..  we do one file per day ourselves..

-Peter
You are not authorized to post a reply.
Forums > Log4Net > Log4Net Mail archive > Question about RollingLogFileAppender



ActiveForums 3.7

 

 

 

 

 

 

 

 

Log4Net Dashboard

Log analysis and monitoring made easy!

Log4Net Dashboard is a log viewer that can read log statements from a variety of logging output targets.

You can download a free developer version.

  

Check it out!

On the demonstration site you can try it  with live data.demo.l4ndash.com - Try Log4Net Dashboard with live data

The mail archive is a copy of all the mail sent to the mail address: log4net-user@logging.apache.org, organized as a forum.

If you would like to participate in the mail list, send a mail to log4net-user-subscribe@logging.apache.org.

More information about the mailing list is available on: http://logging.apache.org/log4net/support.html

 

A complete topic list is available and can be viewed here (warning, it takes some time to load)

 

Copyright 2005-2008 by FaktNet AS Terms Of Use Privacy Statement