ppkarwasz commented on issue #3848:
URL: 
https://github.com/apache/logging-log4j2/issues/3848#issuecomment-3101364042

   Hi @little-hue,
   
   Log4j Core **does** support pre-level-check filtering, and it has since 
version `2.0`.
   
   While it doesn’t use the term *TurboFilter* like Logback, the equivalent 
functionality is implemented via what we call **global filters** — filters 
defined directly under the `<Configuration>` element. These are evaluated 
**before** the logger’s level check and can accept or deny events regardless of 
the configured log level.
   
   ### Example: Accepting Specific Events Regardless of Logger Level
   
   Here’s a minimal example that unconditionally accepts log events with the 
marker `"AUDIT"`, even if the logger level is set higher than the event level:
   
   ```xml
   <Configuration xmlns="https://logging.apache.org/xml/ns";>
     <Appenders>
       <Console name="CONSOLE"/>
     </Appenders>
   
     <!-- Global filter: evaluated before any level checks -->
     <MarkerFilter marker="AUDIT" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
   
     <Loggers>
       <!-- The event is accepted immediately if the global filter returns 
ACCEPT.
            If it returns NEUTRAL, the logger level check still applies. -->
       <Root level="WARN">
         <AppenderRef ref="CONSOLE"/>
       </Root>
     </Loggers>
   </Configuration>
   ```
   
   With this setup, even `DEBUG`-level events tagged with marker `"AUDIT"` will 
be logged, despite the logger being set to `WARN`.
   
   ### For More Information
   
   Log4j Core supports **four types of filters** and **two types of level 
checks**. The official [Filters 
documentation](https://logging.apache.org/log4j/2.x/manual/filters.html) 
provides a detailed explanation — including a [comprehensive 
example](https://logging.apache.org/log4j/2.x/manual/filters.html#example-configuration-file)
 demonstrating all filtering mechanisms working together.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to