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

Custom filters don't work when used context-wide

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Not A Bug
    • 2.14.1
    • None
    • Filters
    • None

    Description

      Better described in https://stackoverflow.com/q/67712907/9721979.

      But in summary, I'm unable to make log4j2 actually call the filters when they are on a context-wide level, contrary to the default/included ones.

      Basically, set up a threshold custom filter, as the example one (which has the same behavior as the default one). When we put the custom one in the context-wide location, in <configuration> tag in log4j2, I see via debugger that the "filter" function isn't even called, but it is being called if using the one included in log4j2. 

      So if the logger level is set to "info" and the thresholdFilter is set to debug, I'm able to see a logger.debug("message") message, but if i do the same with thresholdCustomFilter, then that message isn't logged.

      I attached a sample project with the dependencies and a setup, with a custom filter that should bypass everything. We can check by commenting and uncommenting the two filter lines in the log4j2.xml. The custom filter, which should bypass everything, is not getting considered.

      Attachments

        1. sampleFilterTest.zip
          8 kB
          Mauricio lopez

        Activity

          People

            Unassigned Unassigned
            malopez16 Mauricio lopez
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: