[logback-dev] [JIRA] Commented: (LBCORE-147) RollingPolicy MaxHistory not deleting old files
Ceki Gulcu (JIRA)
noreply-jira at qos.ch
Thu Aug 25 16:23:16 CEST 2011
[ http://jira.qos.ch/browse/LBCORE-147?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12092#action_12092 ]
Ceki Gulcu commented on LBCORE-147:
-----------------------------------
I've spent some time tinkering with various approaches to solve this problem. Launching a scavenging thread sounds like overkill.
The problem stems from the application being quiescent/inactive. If Q is the number of periods where the application was inactive, H is the value of maxHistory and C the current period, then it is sufficient to delete files in interval ranging from (C - H) to (C - (Q+H)) to address the issue at hand, i.e. this bug report. Moreover, it is sufficient to perform deletion of files in the said range only once, when the application starts. Of course, the problem with this approach is that while the values of H and C are known by logback, the value of Q is not.
If there exists a value maxQ such that Q is always smaller than maxQ, we can check and delete all files in the range (C - H) to (C - (maxQ+H)) at application start up. If maxQ is 60 days, then for daily rollover maxQ corresponds to 60 periods and for monthly rollovers to 2 periods. For hourly rollover, it corresponds to 1440 (=60*24) periods, rather a large number. As long as the deletion method is somewhat optimized, the approach just described should work reasonably well even in the case of hourly rollover.
> RollingPolicy MaxHistory not deleting old files
> -----------------------------------------------
>
> Key: LBCORE-147
> URL: http://jira.qos.ch/browse/LBCORE-147
> Project: logback-core
> Issue Type: Bug
> Components: Rolling
> Affects Versions: 0.9.18
> Environment: linux 2.6.18 64bits apache-tomcat-6.0.20 java/jre1.6.0_18
> Reporter: Rafael Diaz Maurin
> Assignee: Ceki Gulcu
> Attachments: TimeBasedRollingWithArchiveRemovalTest.java
>
>
> The MaxHistory does not do the trick : the old files are not deleted at all :
> cat logging.xml
> <appender name="IDP_ACCESS" class="ch.qos.logback.core.rolling.RollingFileAppender">
> <File>/shibboleth-idp/logs/idp-access.log</File>
> <Append>false</Append>
> <ImmediateFlush>true</ImmediateFlush>
> <RollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
> <FileNamePattern>/shibboleth-idp/logs/old/idp-access-%d{yyyy-MM-dd_HH-mm}.log.gz</FileNamePattern>
> <MaxHistory>3</MaxHistory>
> </RollingPolicy>
> <layout class="ch.qos.logback.classic.PatternLayout">
> <Pattern>%msg%n</Pattern>
> </layout>
> </appender>
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the logback-dev
mailing list