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

RollingFileAppender with SizeBasedTriggeringPolicy does not work properly with large size limits

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Abandoned
    • 2.8.2
    • None
    • Appenders
    • None
    • Log4j v.2.8.2 with SLF4J v.1.7.21. Currently running Java version 1.8.0_161. 

    Description

      My application uses a RollingFileAppender with a SizeBasedTriggeringPolicy in which logs should roll over once they reach 50MB in size. However, if the logs exceed this size while the application is running they do not roll over. Only when the application is restarted do the logs get rolled over if they are too big. 

       

      If the size limit is set to 50KB, or 5MB, the rolling over works fine. It seems like only for large size limits like 50MB that this problem occurs. I've attached my log4j2.xml config file to this issue. 

      Here is a snippet containing the RollingFileAppender config: 

      <RollingFile
      append="true"
      name="rootfile"
      fileName="/logs/root.log"
      filePattern="/logs/root.%i.log">
        <DefaultRolloverStrategy fileIndex="min" max="10"/>
        <Policies>
          <SizeBasedTriggeringPolicy size="50000 KB"/>
        </Policies>
        <PatternLayout pattern="[%d{ISO8601}]%5p[%t]%x - %C.%M(%F:%L) - %m%n"/>
      </RollingFile>
      

      Attachments

        1. log4j2.xml
          0.9 kB
          Raphael

        Activity

          People

            Unassigned Unassigned
            Kargon Raphael
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: