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

Ability to change the fileName dynamically in RollingFileAppender

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.1
    • 2.8
    • Appenders
    • None

    Description

      Right now RollingFileAppender rolls over the current file with fileName to the one generated by FilePattern. However, logging always continues in the same fileName i.e. fileName once created cannot be changed.

      Property Substitution is only once during initialization, fileName is never changed after RollingFileManager is initialized. The RollingFileManager is very tightly tied up to the fileName attribute.

      Consider that I want to name my log files like this using RollingFileAppender:

      mylog-2015-10-30.log
      mylog-2015-10-29.log
      mylog-2015-10-28.log

      There is no good way to achieve this, because even after rolling over the file, the fileName would still remain the same. If I initialized my fileName using ${date:yyyy-MM-dd}, date would be substituted only once during initialization and it would never change, always continue to log in the same log file (until I restart my application).

      Attachments

        Issue Links

          Activity

            People

              rgoers Ralph Goers
              dhwaneetbahtt Dhwaneet Bhatt
              Votes:
              4 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: