[logback-dev] [JIRA] Commented: (LBCORE-147) RollingPolicy MaxHistory not deleting old files

Greg Thomas (JIRA) noreply-jira at qos.ch
Mon Feb 21 16:34:52 CET 2011


    [ http://jira.qos.ch/browse/LBCORE-147?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=11965#action_11965 ] 

Greg Thomas commented on LBCORE-147:
------------------------------------

I'm seeing the same problem; can I suggest an alternative, simpler, solution instead of having a persistent list of log files. 

Currently, if maxHistory=5 and the system is quiescent over the weekend so no logs are produced then ...

2011-02-17: Log file created (Thursday), log file for 2011-02-12 deleted if exists.
2011-02-18: Log file created (Friday), log file for 2011-02-13 deleted if exists. 
(2011-02-19: Saturday - No activity)
(2011-02-20: Sunday - No activity)
2011-02-21: Log file created (Monday), log file for 2011-02-16 deleted if exists.

This leaves the files for the 2011-02-14 and 2011-02-15 lying around. 

I'd suggest that a new optional setting is added, "maxHistoryGap" that indicates how far back the old old log files should be deleted (default value=0). If set to 2 (to cope with weekends). This would result in ...

2011-02-17: Log file created (Thursday), log files for 2011-02-12, 2011-02-11, 2011-02-10 deleted if exists.
2011-02-18: Log file created (Friday), log files for 2011-02-13, 2011-02-12, 2011-02-11 deleted if exists. 
(2011-02-19: Saturday - No activity)
(2011-02-20: Sunday - No activity)
2011-02-21: Log file created (Monday), log files for 2011-02-16, 2011-02-15, 2011-02-14 deleted if exists.

I may be able to submit a patch to this effect, if the solution is acceptable.

> 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
>
> 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