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

RegexFilter crashes as context-wide filter

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0-beta5
    • 2.0-beta6
    • Filters
    • None

    Description

      If a RegexFilter is used as a context-wide filter,
      then a call like
      logger.isDebugEnabled()
      leads to a Null-Pointer-Exception, because the RegexFilter is called with the message "null".
      The stack-trace (2.0-beta5) is:
      at org.apache.logging.log4j.core.filter.RegexFilter.filter(RegexFilter.java:60)
      at org.apache.logging.log4j.core.filter.CompositeFilter.filter(CompositeFilter.java:176)
      at org.apache.logging.log4j.core.Logger$PrivateConfig.filter(Logger.java:317)
      at org.apache.logging.log4j.core.Logger.isEnabled(Logger.java:128)
      at org.apache.logging.log4j.spi.AbstractLogger.isTraceEnabled(AbstractLogger.java:1129)

      In the MarkerFilter is the code
      return marker != null && ...
      i.e. it is only necessary to change line 60 to
      return msg != null && filter(msg.toString)
      in RegexFilter (I do not know how to do this correctly...)

      In line 77, this check is done; in line 66 and 72 the same problem may arise...

      Greetings,
      Gerald Kroisandt

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            rgoers Ralph Goers
            kroisand Gerald Kroisandt
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 10m
                10m
                Remaining:
                Remaining Estimate - 10m
                10m
                Logged:
                Time Spent - Not Specified
                Not Specified

                Slack

                  Issue deployment