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

Rolling file does not work with new version of log4j2 2.16 and 2.17.1 versions

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.16.0, 2.17.0
    • None
    • API, Appenders

    Description

      Rolling file is not creating the next day log file and previous day file is being written with new logs in windows tomcat

      Details of logging.properties used: 

       

      rootLogger.level = all
      appenders = rolling, console
      appender.console.type = Console
      appender.console.name = console
      appender.console.layout.type = PatternLayout
      appender.console.layout.pattern = %d [%-5p] (%F:%M:%L) %m%n
      appender.rolling.type = RollingFile
      appender.rolling.name = rolling
      appender.rolling.fileName = C:/Local/Logs/${date:yyyyMMdd}_myfile.log
      appender.rolling.filePattern = C:/Local/Logs/%d{yyyyMMdd}_myfile.log
      appender.rolling.layout.type = PatternLayout
      appender.rolling.layout.pattern = %d [%-5p] [%F:%M:%L] %m%n
      appender.rolling.policies.type = Policies
      appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
      appender.rolling.policies.time.interval = 1
      appender.rolling.policies.time.modulate = true
      rootLogger.appenderRefs = rolling, console
      rootLogger.appenderRef.console.ref = console
      rootLogger.appenderRef.rolling.ref = rolling
      rootLogger.appenderRef.stdout.ref = console, rolling
      

       

      =======================================

      I am using below configuration for the java web application: Tomcat 9.x

      log4j-api-2.16.0.jar

      log4j-core-2.16.0.jar

       

      I even tried with 2.17.1 version as well.

       

      everying working fine , logs are generating but when i trigger the log file next day the logs are triggring in old day file only.

      suppose today (12-01-2022) i am hitting the URL. The file creates and logging data in the file 20220112_myfile.log

      i change the date and hitting the URL again, Here i am expecting the code should create 20220113_myfile.log, but the log file not creating instead all logs are going in the 20220112_myfile.log.

      After i restart the server the new file generating, but i need the file by hitting the URL if it is a different date the log file to be created with the same date, not by restarting the server.

      Can someone help me on this.

      Attachments

        Activity

          People

            Unassigned Unassigned
            Dundigala Srikanth
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: