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

SizeAndTimeBasedRollingPolicy not deleting log files at all

    XMLWordPrintable

Details

    Description

      In my Spring Boot java application (embedded Tomcat server), I have tried using logback version 1.2.2 and 1.2.8 with slf4j version of 1.7.21, the log files are not deleting at all

      The log files are not deleting as per the SizeAndTimeBasedRollingPolicy settings

      <configuration scan="true" scanPeriod="60 seconds">
      <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
      <file>logs/application.log</file>
      <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
                  <fileNamePattern>logs/application_%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern>
                  <maxHistory>14</maxHistory>
                  <totalSizeCap>5GB</totalSizeCap>
                  <maxFileSize>15MB</maxFileSize>
      </rollingPolicy>

       

      When I tried to debug TimeBasedArchiveRemover class of logback core, I can see in method cleanPeriod() the files to be deleted are correctly identified and the code tries to delete them but file.delete returns false due to "The process cannot access the file because it is being used by another process." 

      And when I checked more on which process can be holding the files, it gives the process Id of my java application itself. Not sure what exactly is holding these files and not letting logback delete them

       

       

      Attachments

        Activity

          People

            logback-dev Logback dev list
            neha.sahni Neha Sahni
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: