logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fergus Gallagher <Fergus.Gallag...@OrbisUK.com>
Subject Re: DailyRollingFileAppender - roll at scheduled time instead of when record written
Date Wed, 30 Oct 2002 09:50:28 GMT
DailyRollingFileAppender won't do this in the present incarnation.  It would
require a seperate thread.
 
Options I can think of:

	1) modify DRFA to write the log with the date extension directly, so
it's always available.

	2) (if you have unix) use a simple FileAppender use logrotate from a cronjob. 
You would need to use the 'copytruncate' option which can cause a small
dataloss

	3)  use ExternallyRolledFileAppender and get a cron job to trigger
that.  This uses numerical versioning, I think so possibly not suitable.

	4) Use a Timer/TimerTask to write a log message at midnight (or
maybe 1s past, to be safe!)

(4) is certainly the easiest.....

Fergus

ASIDE: I generally log to ConsoleAppender which is redirected by the OS. I
prefer this so I can get output from parts of the application that don't use
Log4J (3rd party libs, JVM stacktraces, etc)

On Tue, Oct 29, 2002 at 06:05:08PM -0800, David Sanders wrote:
> With DailyRollingFileAppender, how do I cause files to be rolled over on 
> the configurable interval instead of waiting for the first log write 
> attempt after the interval expires?
> 
> http://jakarta.apache.org/log4j/docs/api/org/apache/log4j/DailyRollingFileAppender.html

> said:
> 
> > DailyRollingFileAppender extends FileAppender so that the underlying 
> file is rolled over at a user chosen frequency.
> >For example, if the File option is set to /foo/bar.log and the 
> DatePattern set to '.'yyyy-MM-dd, on 2001-02-16 at midnight, the logging 
> file >/foo/ bar.log will be copied to /foo/bar.log.2001-02-16 and logging 
> for 2001-02-17 will continue in /foo/bar.log until it rolls over the next 
> day.
> 
> The file won't be rolled on 2001-02-16 at midnight unless a message is 
> logged at midnight.  Instead, the file will be rolled when the first log 
> message is written after midnight.  In my application, that "first message" 
> could be several hours after midnight.  Yet, I need the log file closed 
> (and preferably renamed) at midnight so the log can be processed by another 
> program.
> 
> 
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:log4j-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:log4j-user-help@jakarta.apache.org>

-- 
Fergus Gallagher          Tel: +44 (20) 8742 1600
Orbis                     Fax: +44 (20) 8742 2649
414 Chiswick High Street  email: Fergus.Gallagher@orbisuk.com
London  W4 5TL            Web: http://www.orbisuk.com

--
To unsubscribe, e-mail:   <mailto:log4j-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:log4j-user-help@jakarta.apache.org>


Mime
View raw message