[logback-dev] [JIRA] Commented: (LBCORE-147) RollingPolicy MaxHistory not deleting old files
Greg Thomas (JIRA)
noreply-jira at qos.ch
Wed Aug 17 22:57:16 CEST 2011
[ http://jira.qos.ch/browse/LBCORE-147?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12084#action_12084 ]
Greg Thomas commented on LBCORE-147:
------------------------------------
You're right, in that I know think that implementing the "maxHistoryGap" solution I referred to earlier is the right solution.
Instead, I think that when a new log file is created, rather than just delete the "oldest+1" file, it's necessary to do a full directory scan, and delete all those that are too old - that copes for longer quiet periods.
Of course, it's complicated because your not just dealing with files called, e.g. "2011-02-12.log", but they could be called "2011/02/12/data.log" - i.e. it's necessary to do a recursive directory scan.
Ceki; if you think that solution is acceptable, let me know and I'll see if I can work on a fix for it.
PS. For those looking the other (working) appender mentioned in this ticket, org.apache.log4j.appender.TimeAndSizeRollingAppender is, despite the name, not part of the Apache project - you can find more details on this at http://www.simonsite.org.uk/ - from a quick glance, it too appears to "scavenge" older files on a configurable interval. I don't think that's necessary in this case; older files only need to be scavenged when a new one is created.
> 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