On Jan 28, 2008, at 10:30 AM, Stefan Fleiter wrote:
Hello,
we think that Log4j is missing a possibility to rollover at a fixed
time of the day
and have developed a TimedDailyRollingFileAppender class which does
this.
We would like to contribute the solution to the log4j project.
If there is interest in this class we could factor out the
similarities
with DailyRollingFileAppender and send a patch.
The class can be configured like this:
log4j.appender.file=org.apache.log4j.TimedDailyRollingFileAppender
log4j.appender.file.File=${filename}
log4j.appender.file.RolloverHour=5
log4j.appender.file.RolloverMinute=55
Alternatively, if this is not flexible enough, we could extend the
configurability
by converting this class to a CronExpressionFileAppender which accepts
a cron expression for rollover:
log4j.appender.file=org.apache.log4j.TimedDailyRollingFileAppender
log4j.appender.file.File=${filename}
log4j.appender.file.RolloverCronExpression=0 55 5 * * *
To do this we would depend on CronExpression from Quartz:
http://svn.opensymphony.com/fisheye/viewrep/quartz/trunk/src/java/org/quartz/CronExpression.java
Quartz is licensed under the Apache License, Version 2.0, so this
should be no problem.
What do you think?
Greetings,
Stefan Fleiter
I think it would be better to provide a TimeTriggeringPolicy or a
CronExpressionTriggeringPolicy that works with the
org.apache.log4j.rolling.RollingFileAppender in the extras companion (http://logging.apache.org/companions/extras
) which is a collection of enhanced features for log4j 1.2.x.
I think it would be better to avoid adding a dependency to pick up the
CronExpression since that would likely force the Policy off into a yet
another companion since we would not want to force everyone who uses
extras to pick up quartz.
I guess you could provide a SimpleDateFormat pattern and matching
value string that could be used for the trigger whenever it went
over. You'd also want to have some logic to prevent erroneous
multiple rollovers if the timestamps were out of sequence (can occur
in multi-threaded apps).
The org.apache.log4j.rolling.RFA is not configurable from properties
files, but requires use of the DOMConfigurator if that is a concern.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]