logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Curt Arnold <carn...@apache.org>
Subject Re: RollingFileAppender with stable filenames?
Date Sun, 14 Aug 2005 19:17:50 GMT

On Aug 14, 2005, at 9:23 AM, Iain.Shepherd@barclayscapital.com wrote:

> Hi,
>
> I'm writing a program which will frequently scan and parse log files.
>
> I want to use RollingFileAppender to write them, but I'm not 100%  
> happy
> with its behaviour. I'd have to allow for all the filenames to change
> between one scan and the next, or even, conceivably, while I'm  
> actually
> in the middle of a scan.
>
> So I'd like a RollingFileAppender that uses stable filenames, in
> sequence:
>
> my.log.1 << Deleted, because MaxBackupIndex=2
> my.log.2
> my.log.3
> my.log.4 << Current file
>
>
> Before I knuckle down and write one myself, I just thought I'd ask
> whether anyone else has done this?
>
> I did find Geoff Mottram's DatedFileAppender, but I'm really  
> looking for
> something based on RollingFileAppender so I don't have any time-based
> issues at all (some of the programs will be running in different time
> zones...)
>
> Ta for any advice.
>
> Iain Shepherd


There are two different RollingFileAppender implementations in log4j:  
org.apache.log4j.RollingFileAppender which has been around for a  
while and org.apache.log4j.rolling.RollingFileAppender (with an  
extra .rolling in the package name) that was introduced in the log4j  
1.3 branch.  The "new" RFA allows pluggable TriggeringPolicy (when to  
initiate a rollover) and RollingPolicy (how the files are named).   
Your scenario looks like it would be able to use the existing  
SizeBasedTriggeringPolicy but would need a custom RollingPolicy (or  
some enhancement to the FixedWindowRollingPolicy).

You didn't mention if you were looking for something on the log4j 1.2  
branch or the 1.3 branch.  It seems plausible to add a suitable  
rolling policy to the 1.3 branch.  I don't think enhancing the  
FixedWindowRollingPolicy would be appropriate since the new behavior  
would be inconsistent with the name.

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message