You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Ia...@barclayscapital.com on 2005/08/14 16:23:58 UTC
RollingFileAppender with stable filenames?
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
------------------------------------------------------------------------
For more information about Barclays Capital, please
visit our web site at http://www.barcap.com.
Internet communications are not secure and therefore the Barclays
Group does not accept legal responsibility for the contents of this
message. Although the Barclays Group operates anti-virus programmes,
it does not accept responsibility for any damage whatsoever that is
caused by viruses being passed. Any views or opinions presented are
solely those of the author and do not necessarily represent those of the
Barclays Group. Replies to this email may be monitored by the Barclays
Group for operational or business reasons.
------------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
Re: RollingFileAppender with stable filenames?
Posted by Curt Arnold <ca...@apache.org>.
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