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

Logger is logging logs in the wrong date file.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Critical
    • Resolution: Unresolved
    • 2.17.1
    • None
    • Log4j-to-SLF4J
    • None

    Description

      One of our applications is using log4j2 version 2.17.1 with slf4j.
      Here we are facing issue of logging of logs in the older date files like logs which should go to 19-july-2023 those are actually getting logged in 18-july-2023.
      Lately also observed that it is logging logs of 8-aug-2023 logs in 3-aug-2023 file.
       
      we have tried setting timezone as well but still the issue persists, following is the configuration for the same.
      <properties>
      <property name="log4j.rootLogger.timezone" value="CDT" />
      </properties>
       
      Here is the appender configuration in log4j2.xml,

      <EcwRollingRandomAccessFile name="FILE" 
          fileName="${sys:pathfile}/${date:yyyy-MM-dd}.log"
          filePattern="${sys:pathfile}/%d{yyyy-MM-dd}.log.gz"
          immediateFlush="true" append="true">
        <PatternLayout pattern="%-5p | %d{yyyy-MM-dd HH:mm:ss zzz} | ${sys:AppVer} | [%t] %C{2} (%F:%L) - %m | %X%n" />
        <Policies>
          <TimeBasedTriggeringPolicy interval="1" modulate="true" />
        </Policies>
        <DefaultRolloverStrategy>
          <Delete basePath="${sys:pathfile}">
            <IfFileName glob="//*.log.gz" />
            <IfLastModified age="60d" />
          </Delete>
        </DefaultRolloverStrategy>
      </EcwRollingRandomAccessFile> 

       
      Here is the list of jars we are using in our application.
      log4j-api-2.17.1.jar
      log4j-core-2.17.1.jar
      log4j-slf4j-impl-2.17.1.jar
      slf4j-api-1.7.36.jar 
       
       Please check attached screenshot of logs.
      Could you please suggest let us know and suggest the solution around it? 

      Attachments

        Activity

          People

            rgoers Ralph Goers
            Sawaliya Rupesh
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: