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

Alexander Lauper (JIRA) noreply-jira at qos.ch
Wed Aug 17 11:49:16 CEST 2011


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

Alexander Lauper commented on LBCORE-147:
-----------------------------------------

Hello

Same situation here (logback 0.9.26, linux 2.6.26) using TimeBasedRollingPolicy. 

maxHistory is set to 30 (days) but I got 33 log files (would have expected 31). It's possible that the machine wasn't running for 2 days.

As I am using this on a embedded device which might be out of service for 0 to infinite days the solution suggested by Greg Thomas would not work well for me.

The documentation says:
"The maxHistory property controls the maximum number of archive files to keep, deleting older files. For example, if you specify monthly rollover, and set maxHistory to 6, then 6 months worth of archives files will be kept with files older than 6 months deleted."

I am very sorry, but this is not implemented that way. The current implementation deletes the one and only file based on the current date. According to the doc I guess most people (including me) would expect that there will never be more files than maxHistory + 1 regardless of any gaps the machine/application wasn't running. I strongly assume this would be the generally desired behaviour.

An extreme example would be setting maxHistory to 1 and let the machine/application run every other day only. In this case I guess (didn't test it) the amount of files would grow indefinitely. On an unattended embedded device this might lead to a catastrophic situation (disk/flash space running out).

What's the status on this issue? It was opened over a year ago ...

Apart from that I love logback. Keep up the good work!

Kind regards,
Alex

> 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