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

TimeBasedRollingPolicy with MaxHistory would not delete log file created by startup with 0 size

    XMLWordPrintable

Details

    Description

      TimeBasedRollingPolicy with MaxHistory would not delete log file created by startup with 0 size.

       

      logback.xml

          <appender name="TRANSACTION_LOG" class="ch.qos.logback.core.rolling.RollingFileAppender">
              <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
                  <FileNamePattern>${LOG_DIR}/transaction_%d{yyyy-MM-dd-HH}.log</FileNamePattern>
                  <MaxHistory>5</MaxHistory>
              </rollingPolicy>
              <encoder>
                  <pattern>%msg%n</pattern>
              </encoder>
          </appender>
      

       before rolling:

      -rw-r--r-- 1 root root      0 Feb 28 08:23 transaction_2019-02-28-08.log
      -rw-r--r-- 1 root root      0 Feb 28 10:02 transaction_2019-02-28-10.log
      -rw-r--r-- 1 root root  13466 Feb 28 17:43 transaction_2019-02-28-17.log
      -rw-r--r-- 1 root root    530 Feb 28 19:04 transaction_2019-02-28-19.log
      -rw-r--r-- 1 root root    530 Feb 28 20:25 transaction_2019-02-28-20.log
      

      after:

      -rw-r--r-- 1 root root      0 Feb 28 08:23 transaction_2019-02-28-08.log
      -rw-r--r-- 1 root root      0 Feb 28 10:02 transaction_2019-02-28-10.log
      -rw-r--r-- 1 root root   4563 Mar  1 03:35 transaction_2019-03-01-03.log
      

       

      restart at 7:56 then rolling

      -rw-r--r--. 1 root root       0 Feb 28 08:23 transaction_2019-02-28-08.log
      -rw-r--r--. 1 root root       0 Feb 28 10:02 transaction_2019-02-28-10.log
      -rw-r--r--. 1 root root    4563 Mar  1 03:35 transaction_2019-03-01-03.log
      -rw-r--r--. 1 root root    2529 Mar  1 04:02 transaction_2019-03-01-04.log
      -rw-r--r--. 1 root root    2528 Mar  1 05:28 transaction_2019-03-01-05.log
      -rw-r--r--. 1 root root    2528 Mar  1 06:09 transaction_2019-03-01-06.log
      -rw-r--r--. 1 root root    2527 Mar  1 07:07 transaction_2019-03-01-07.log
      -rw-r--r--. 1 root root    2538 Mar  1 08:03 transaction_2019-03-01-08.log
      

       

      issue:

      transaction_2019-02-28-08.log and transaction_2019-02-28-10.log havent been deleted

       

      they were created in startup with no content

      Attachments

        Activity

          People

            logback-dev Logback dev list
            xylty Tianyu Li
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: