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

Logback : TimeBasedRollingPolicy does not change the directory sometimes

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Critical Critical
    • None
    • 1.0.9
    • logback-core
    • None

    Description

      I'm using the logback in my application and following rolling file appender.

      <appender name="OVERALL_SYNCHRONOUS" class="ch.qos.logback.core.rolling.RollingFileAppender">
          <Append>true</Append>
          <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
              <!-- Daily rollover -->
      
              <fileNamePattern>${logRoot}/${dirName}/application_overall.log.zip</fileNamePattern>
          </rollingPolicy>
          <encoder>
               <pattern>%d{dd.MM.yy HH:mm:ss.SSS} [%-5level] %65.65(%logger{0}.%aspectjFreeMethod\(%line\)): %X{MDC_CtrlName}%msg%n</pattern>
          </encoder>
      </appender>
      

      This works fine most of the times but sometimes on the day change it zips the previous that is as expected but does not change the directory for the new log file. It creates the new file in the same folder of the previous day.

      When day changes from 18.11.15 to 19.11.15 application zipped the application_overall.log as it should and create "application_overall.log.zip". But application continues to log in the application_overall.log in the folder "2015-11-18". No application_overall.log was created in the folder "2015-11-19" whereas all the other log files of the application were zipped in folder "2015-11-18" and a new log file is created in the current date folder i.e. "2015-11-19".

      After restarting, a new log file of application_overall.log was created in the folder "2015-11-19".

      EDIT: logroot and dirName are defined as below :-

      <insertFromJNDI env-entry-name="java:comp/env/log/logRoot" as="logRoot"     
      scope="context"/>
          <insertFromJNDI env-entry-name="java:comp/env/log/dateDirNamePattern" as="datePattern" scope="context"/>
      <property name="dirName" value="%d{${datePattern:-yyyy-MM-dd}}" scope="context"/>
      

      What could be the possible reason for this behaviour and how can I solve this issue?

      Attachments

        Activity

          People

            logback-dev Logback dev list
            abhishek_mundewal AbhishekMundewal
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: