logging-log4net-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dominik Psenner" <dpsen...@gmail.com>
Subject RE: log4net RollingLogFileAppender: is this possible to set limit for TOTAL size of all log files?
Date Tue, 25 Sep 2012 10:10:04 GMT
>If I set
>maximumFileSize=10MB and maxSizeRollBackups=10, I will get 10 files for a
><Day>  with total size 100MB. During the next day (<Day+1>) I will get
>another  10 files for the <Day+1>  with total size 100MB; the previous 10
>files (ones for the <Day>) will NOT be removed when new files (for the
><Day+1>) start appearing.
>I really tested the Appender in such situation.
>So, the limit affects EACH SINGLE DAY; but not the whole bunch of .log
>in teh given folder

Now I got your point. However, keeping files of past days once the rolling
runs by date is a feature documented also at [2]. There it says:

-- quote --
This example show how to configure the RollingFileAppender to roll log files
on a date period and within a date period on file size. For each day only
the last 10 files of 1MB will be kept.
-- eof quote --

Since you only want to limit the file count anyway, it makes sense to not
roll by date but by file size, doesn't it? Doing so gives you the wanted
behaviour, but filenames won't contain the date. Sorry for the

Clearly the above is only a workaround and a date in the filename would be
nice, but it is not trivial to implement such a rolling without being
computationally expensive.

The problem lies in identifying the files that should be deleted even if
those files are many thousands or their filename contains a date that is
years in the past. One can either probe a filename or probe if there is a
file for a specific date. Both strategies do not fit into the current
implementation of the rolling file appender. There are several known
problems with the rolling file appender and a rewrite is in discussion. To
document this discussion I've CC'ed the dev mailing list.

If you believe that you need this as a feature, please leave a feature
request in JIRA at [1]. Of course it is no guarantee that one of the
developers will work on this issue any time soon, and therefore I encourage
you to actively work on it if you need it soon. Patches that improve log4net
are always welcome!

Best regards,

[1] https://issues.apache.org/jira/browse/LOG4NET
[2] http://logging.apache.org/log4net/release/config-examples.html

View raw message