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

   > Perhaps a configuration to name the context selector class?
   
   There is already 
[`log4j2.contextSelector`](https://logging.staged.apache.org/log4j/2.x/manual/systemproperties.html#log4j2.contextSelector)
 configuration property that does that.
   
   > re: ContextNameSelector -- perhaps a package prefix selector?
   
   While you can create a `ContextSelector` based on the FQCN of the caller, 
that wouldn't necessarily be a good way to split loggers between logger context.
   
   Ideally you don't only want to split the loggers of the classes in the 
`order`, `quote` and `billing` packages into 3 separate logger contexts, you 
would like also to split the loggers of the common libraries into 3 separate 
logger contexts. Of course this requires those libraries to be carefully 
written with log separation in mind: they need to use exclusively **instance** 
logger fields instead of the more popular **static** logger fields.
   
   **Note**: In practice separating the loggers of common libraries of a 
runtime environment is almost impossible. A more practical approach is to add 
some context data (see `ThreadContext` for example) to each log entry, log 
everything to one big file and split it afterwards.


-- 
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