Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-2625

Log file not getting rolled over with compression in Time based policy

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Abandoned
    • None
    • None
    • API
    • None
    • org.apache.logging.log4j : log4j-slf4j-impl : 2.9.0

      Open jdk 8

    Description

      I have configured our application to roll over log file each day and delete it after 3 days. The current log file is having the current date (yyyy-mm-dd format). The configuration is as below:

       

      // <?xml version="1.0" encoding="UTF-8"?>
      <Configuration status="warn">
      <Properties>
      <Property name="globPattern">${env:LOG_FILE_NAME}*.log.gz</Property>
      </Properties>
      <Appenders>
      <RollingFile name="fileLogger" fileName="${env:LOG_DIR}/${env:LOG_FILE_NAME}-${date:yyyy-MM-dd}.log"
      filePattern="${env:LOG_DIR}/${env:LOG_FILE_NAME}-%d{yyyy-MM-dd}.log.gz">
      <PatternLayout>
      <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%level] %c{1} - %msg%n</pattern>
      </PatternLayout>
      <Policies>
      <TimeBasedTriggeringPolicy interval="1" modulate="true" />
      </Policies>
      <DefaultRolloverStrategy>
      <Delete basePath="${env:LOG_DIR}" maxDepth="1">
      <IfFileName glob="${globPattern}" />
      <IfLastModified age="3d" />
      </Delete>
      </DefaultRolloverStrategy>
      </RollingFile>
      
      <Console name="console" target="SYSTEM_OUT">
      <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%level] %c{1} - %msg%n" />
      </Console>
      </Appenders>
      <Loggers>
      
      <Root level="${env:LOG_LEVEL}" additivity="true">
      <appender-ref ref="fileLogger" />
      <!-- <appender-ref ref="console" /> -->
      </Root>
      </Loggers>
      </Configuration>
      

       

      But the issue is, on next day, file is getting rolled over but not making it compressed, simply creating a new log file with next date.

      Attachments

        Activity

          People

            Unassigned Unassigned
            kmatul Kumar Atul
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: