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

RollingFileAppender with DirectWriteRolloverStrategy does not work with HtmlLayout

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.13.1
    • Appenders
    • None

    Description

      When I try to use the RollingFileAppender with a DirectWriteRolloverStrategy and a HtmlLayout, I encountered a bug: The first file that is written does not start with the header from the layout.

      If I try to specify append=false to work around that issue, I encountered a NullPointerException instead:

      java.lang.NullPointerException
       at java.io.File.<init>(File.java:277)
       at org.apache.logging.log4j.core.appender.FileManager.createOutputStream(FileManager.java:140)
       at org.apache.logging.log4j.core.appender.OutputStreamManager.getOutputStream(OutputStreamManager.java:166)
       at org.apache.logging.log4j.core.appender.OutputStreamManager.<init>(OutputStreamManager.java:95)
       at org.apache.logging.log4j.core.appender.FileManager.<init>(FileManager.java:72)
       at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.<init>(RollingFileManager.java:98)
       at org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory.createManager(RollingFileManager.java:627)
       at org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory.createManager(RollingFileManager.java:588)
       at org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:113)
       at org.apache.logging.log4j.core.appender.OutputStreamManager.getManager(OutputStreamManager.java:114)
       at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.getFileManager(RollingFileManager.java:163)
       at org.apache.logging.log4j.core.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:142)

      I will create a PR in github with a TestCase and a fix and attach it to this bug report.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              christophk Christoph Kaser
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 40m
                  40m