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

   @ranger2025,
   
   ### Filtering by module name
   
   To filter by module name you can use the existing 
[`ScriptFilter`](https://logging.apache.org/log4j/2.x/manual/filters.html#Script).
 For example, using Groovy you can write:
   
   ```xml
   <ScriptFilter>
     <Script language="groovy"><![CDATA[
       return "foo.bar.baz".equals(logEvent.getSource()?.moduleName)
     ]]></Script>
   </ScriptFilter>
   ```
   
   Most of the [out-of-the-box 
filters](https://logging.apache.org/log4j/2.x/manual/filters.html#collection) 
contained in Log4j Core 2 are inherited from Log4j 1. New filters are unlikely 
to be added to the collection unless:
   
   - They prove to be useful to many users.
   - And they can not be implemented efficiently using scripts.
   
   Could you explain more, why do you need to filter by module name?
   
   ### Filtering by module layer
   
   Could you explain the purpose of filtering by module layer?
   
   My guess is that you have a multi-application runtime and you want to 
separate the logs from different applications. In this case you probably don't 
need filters, but something similar to the [Jakarta EE log separation 
features](https://logging.apache.org/log4j/2.x/jakarta.html#log-separation):
   
   - Either you want to implement a 
[`ContextSelector`](https://logging.apache.org/log4j/2.x/manual/extending.html#ContextSelector)
 that assigns separate [logger 
contexts](https://logging.apache.org/log4j/2.x/manual/architecture.html#LoggerContext)
 to separate module layers.
   - Or you want to implement a 
[lookup](https://logging.apache.org/log4j/2.x/manual/lookups.html) to be able 
to tag each log event with the "name" of the module layer that generated it.
   


-- 
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: notifications-unsubscr...@logging.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to