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

Feature request: auto-delete older rolled over files

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 2.0-beta9, 2.0-rc1
    • Fix Version/s: None
    • Component/s: Appenders
    • Labels:

      Description

      This issue was raised by Kireet on the log4j-user mailing list:

      I am trying to use the rolling file appender in log4j2, basically I want to roll at midnight daily and keep 3 old log files. New files are created properly, but log4j doesn't seem to be cleaning up the old files. Does log4j only support cleanup of files within the time period? Here is the relevant portion of the config. I tried things with and without the %i pattern.

          <RollingFile name="Event" fileName="app.log"
                       filePattern="app-%d{yyyy-MM-dd}.%i.log">
            <PatternLayout>
              <Pattern>%m%n</Pattern>
            </PatternLayout>
            <Policies>
              <TimeBasedTriggeringPolicy interval="1" modulate="true"/>
            </Policies>
            <DefaultRolloverStrategy compressionLevel="0" max="3"/>
          </RollingFile>
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                rpopma Remko Popma
              • Votes:
                20 Vote for this issue
                Watchers:
                22 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: