[logback-user] TimeBasedRollingPolicy
Ceki Gulcu
listid at qos.ch
Tue Oct 14 17:50:54 CEST 2008
Gam wrote:
> On 12 Oct 2008, at 21:40, logback-user-request at qos.ch wrote:
>
>> thanx for your response. my test-application ran under a minute.
>> and now it's clear to me that every time
>> i restart the application the logging-configuration starts from
>> scratch. therefore i never had a rollover.
>> I introduced a sleep to make my app run longer than a minute; and
>> it works. thanks for your help.
>
> I discovered the same. I've been using log4j for years and it behaves
> differently than logback in this context, it will roll the log
> according to the configuration regardless of the execution context,
> which is imho a better behavior. I hope it would be possible to fix
> this issue or at least give an option between the two behaviors.
>
> Here is how I use it:
> - I have a monitoring task that is run every ten minutes and lasts
> for a dozen of seconds. I set logback to roll the logs everyday but
> it never happens because logback rolls ONLY if it is running while
> the date changes. I end up with a very huge log file that never rolls.
> Log4j will roll it during the first new execution after the date has
> changed.
Hello Gam,
I must say that was initially surprised by your comments. Log4j and logback
should behave exactly in the same way regarding this point. I should know
because I wrote the rolling code in both cases. Both log4j and logback will roll
over the file as soon as a logging event occurs subsequent to the roll over
point. For example, for daily rolling, the fist logging event after midnight
will trigger roll over.
However, it is true that DailyRollingFileAppender in log4j will check (during
initialization) the modification date of the current log file and if the
modification time belongs to a previous period which would have been rolled over
had the appender been active, then DailyRollingFileAppender will perform the
rollover during its initialization. So, indeed, logback behaves differently than
log4j.
> What do you think?
I think the issue warrants a jira entry. :-)
> Gam.
--
Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.
http://logback.qos.ch
More information about the Logback-user
mailing list