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

RollingFileAppender OnStartupTriggerPolicy fails when append="false"

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.2
    • None
    • Appenders
    • None
    • Windows

    Description

      I want to Roll the File on startup and when the file is 1MB. The current file should be cleared when the roll happens so append="false". When append is false the startup trigger clears the main file without rolling it.

      If i set append to "true". the startup trigger rolls the file properly but then it keeps appending so my first rolled log is 1MB, the second is 2MB, the third is 3MB. and so that the main file just keeps growing and the rolled files are each an increment bigger than the previous.

      <?xml version="1.0" encoding="UTF-8"?>
      <Configuration status="WARN">
          <Properties>
              <Property name="patternLayout">%d{yyyy-MM-dd HH:mm:ss.SSS} [%10.10t] %X{client} %-5p %c{2} - %m%n</Property>
          </Properties>
          <Appenders>
              <RollingFile name="ProbeFile" fileName="probe.log" filePattern="probe-%i.log" append="false">
                  <PatternLayout pattern="${patternLayout}"/>
                  <Policies>
                      <OnStartupTriggeringPolicy />
                      <SizeBasedTriggeringPolicy size="1 MB"/>
                  </Policies>
                  <DefaultRolloverStrategy max="10"/>
              </RollingFile>
          </Appenders>
      
          <!-- Logger Levels: all, trace, debug, info, warn, error, fatal, off -->
          <Loggers>
              <Root level="info">
                  <AppenderRef ref="ProbeFile"/>
              </Root>
          </Loggers>
      </Configuration>
      

      Attachments

        Activity

          People

            rgoers Ralph Goers
            DClutter25 David Clutter
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: