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

ObjectFilter parameters not expanded by JPL

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • None
    • JPL Adapter
    • None

    Description

      The JPL leaves parameters unexpanded. This can be seen in the attached sample project ([also available on GitHub|https://github.com/travisspencer/log4j-jpl-bug).] As discussed on the mailing list, I added log4j-jpl-2.17.1.jar to my class path. I then added this to my log4j config file:
       
      <Logger name="java.io.serialization" level="TRACE" />
       
      Now, I see this in my log file:
       
      2022-01-04T15:05:52:849+0100 TRACE 8P1u2Wr5 dd4ec2e6 {req-169} java.io.serialization:-1 ObjectInputFilter {0}: {1}, array length: {2}, nRefs: {3}, depth: {4}, bytes: {5}, ex: {6}
       
      Looking at the OpenJDK 11 code at java.base/java/io/ObjectInputStream.java:1345, I see this:
       
      Logging.filterLogger.log(status == null || status == ObjectInputFilter.Status.REJECTED
                                      ? Logger.Level.DEBUG
                                      : Logger.Level.TRACE,
                              "ObjectInputFilter {0}: {1}, array length: {2}, nRefs: {3}, depth: {4}, bytes: {5}, ex: {6}",
                              status, clazz, arrayLength, totalObjectRefs, depth, bytesRead,
                              Objects.toString(ex, "n/a"));
       
      This logger seems to be set above this on line 300ish:
       
      static {
                  Logger filterLog = System.getLogger("java.io.serialization");
                  filterLogger = (filterLog.isLoggable(Logger.Level.DEBUG)
                          || filterLog.isLoggable(Logger.Level.TRACE)) ? filterLog : null;
      {{        }}}
       
      So, the placeholders don't seem to get changed for their parameter values.
       
      As pointed out on the mailing list:
       

      MessageFormatMessage` should have been used instead of
      `ParametrizedMessage`

       
      ggregory asked that if this change is made when fixing the bug, a comment is added to say why.

      Attachments

        1. log4j-jpl-bug-main.zip
          5 kB
          Travis Spencer

        Issue Links

          Activity

            People

              Unassigned Unassigned
              tspencer Travis Spencer
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: