Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-107

SiftingAppender TimeBasedRollingPolicy MaxHistory not deleting old files

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • None
    • logback-core
    • None
    • linux64, jdk1.6.0_17-b04, apache-tomcat-6.0.24

    Description

      When I use SiftingAppender with TimeBasedRollingPolicy, old files does not get deleted when the MaxHistory is set.

      logback.xml snipet:

      <configuration debug="true" scan="true" scanPeriod="5 seconds">
      <appender name="SIFT" class="ch.qos.logback.classic.sift.SiftingAppender">
      <discriminator>
      <Key>userid</Key>
      <DefaultValue>base</DefaultValue>
      </discriminator>
      <sift>
      <appender name="FILE-${userid}" class="ch.qos.logback.core.rolling.RollingFileAppender">
      <File>/usr/local/tomcat6/logs/myLog_${userid}.log</File>
      <Append>false</Append>
      <layout class="ch.qos.logback.classic.PatternLayout">
      <Pattern>%d [%thread] %level %mdc %logger.%method:%line - %msg%n</Pattern>
      </layout>
      <RollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
      <FileNamePattern>/usr/local/tomcat6/logs/myLog_${userid}.%d

      {yyyy-MM-dd}.log</FileNamePattern>
      <!-- not working -->
      <MaxHistory>2</MaxHistory>
      </RollingPolicy>
      </appender>
      </sift>
      </appender>
      ...

      With the config above, the files gets sifted and rolled well, but old files not deleted.

      When I change the filenames, and delete the ${userid} sifting, it works well.

      ...
      <File>/usr/local/tomcat6/logs/myLog.log</File>
      ...
      <FileNamePattern>/usr/local/tomcat6/logs/myLog.%d{yyyy-MM-dd}

      .log</FileNamePattern>
      ...

      Attachments

        Activity

          People

            logback-dev Logback dev list
            roti Hrotkó Gábor
            Votes:
            3 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: