PatternLayout Does not work

I can’t get the PatternLayout to work. It seems like it just falls back to the Classic layout.

Anyone seen this issue before?
Can anyone demonstrate a working config?

here is what the generated CFConfig.json looks like

"exception": {
      "appenderArguments": {
        "charset": "UTF-8",
        "path": "{lucee-config}/logs/exception.log",
        "maxfiles": "10",
        "maxfilesize": "10485760",
        "timeout": "0"
      },
      "level": "error",
      "appenderClass": "lucee.commons.io.log.log4j2.appender.ResourceAppender",
      "layoutClass": "org.apache.logging.log4j.core.layout.PatternLayout",
      "layoutArguments": {
        "pattern": "%d{dd.MM.yyyy HH:mm:ss,SSS} %-5p [%c] %m%n"
      }
    }

Docker FROM lucee/lucee:6.1.1.118

Maybe someone with more experience in the java source code can eval this?

"exception": {
   "appender": "resource",
   "appenderArguments": {
      "path": "{lucee-config}/logs/exception.log"
   },
   "level": "error",
   "layout": "pattern",
   "layoutArguments": {
      "pattern": "%d{yyyy-MM-dd HH:mm:ss,SSS} [%t] %-5p %c - %m%n"
    }
}

The Root Cause: A Bug in ResourceAppender

The problem is not in your configuration, but in how Lucee’s ResourceAppender interacts with Log4j2’s PatternLayout.

  1. Null Header: When you specify "layout": "pattern", Lucee correctly creates a PatternLayout instance. By default, this layout does not have a header, so its getHeader() method returns null.
  2. The Bug: The ResourceAppender code attempts to create the log file and write a header. The code at core/src/main/java/lucee/commons/io/log/log4j2/appender/ResourceAppender.java:141 is:
String header = new String(getLayout().getHeader(), charset);

When getLayout().getHeader() returns null, this line becomes new String(null, charset), which causes the NullPointerException you are seeing. The appender does not correctly handle a layout that has no header.

Because Lucee’s configuration mechanism doesn’t provide a way to add a header to the PatternLayout, you cannot work around this bug while still using the "pattern" layout with the "resource" appender.