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

Custom java.util.logging.Level gives null Log4j Level and causes NPE

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.3
    • Fix Version/s: 2.4
    • Component/s: JUL adapter
    • Labels:
      None

      Description

      I use a 3rd party library which uses custom non-standard java.util.logging.Level.

      The Log4j JUL adapter will emit log event with level set to null in that case, which causes NullPointerException in a Log4j filter further on.

      This is not acceptable. When encountering an unrecognised JUL Level, the JUL adapter should either:

      • emit some default Log4j Level
      • throw an Exception with a clear error message immediately
      • silently discard the log event
      • discard the log event and log a warning to the StatusLogger
       java.lang.NullPointerException
              at org.apache.logging.log4j.Level.isMoreSpecificThan(Level.java:163)
              at org.apache.logging.log4j.core.filter.BurstFilter.filter(BurstFilter.java:129)
              at org.apache.logging.log4j.core.filter.BurstFilter.filter(BurstFilter.java:101)
              at org.apache.logging.log4j.core.Logger$PrivateConfig.filter(Logger.java:295)
              at org.apache.logging.log4j.core.Logger.isEnabled(Logger.java:122)
              at org.apache.logging.log4j.spi.ExtendedLoggerWrapper.isEnabled(ExtendedLoggerWrapper.java:87)
              at org.apache.logging.log4j.spi.AbstractLogger.logIfEnabled(AbstractLogger.java:699)
              at org.apache.logging.log4j.jul.WrappedLogger.log(WrappedLogger.java:50)
              at org.apache.logging.log4j.jul.ApiLogger.log(ApiLogger.java:106)
      

        Attachments

        1. LOG4J2-1025.patch
          11 kB
          Gary Gregory
        2. LOG4J2-1025-2.patch
          0.8 kB
          Mikael Ståldal

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              mikaelstaldal Mikael Ståldal
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: