You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by ar...@cornell.edu on 2001/02/27 21:23:59 UTC

Multiple configurations

Hello,

  I was wondering if it were possible to have multiple configurations 
within the same VM, for instance, one per category, or one per "realm" 
which is a set of categories (perhaps a given class hierarchy).  At first 
look, it seems like all configuration is global in the VM, so that the 
last configure() call "wins" the configuration and clobbers any 
previously defined (perhaps identically named?) appenders.

Here is my situation:  Imagine one has a package com.foo.package1 and 
com.foo.package2.  These are utility packages that can be used alone or 
together within a greater application.  I wish each of these packages to 
do their own logging, unseen to the developer.  I wish the 
com.foo.package1 package to be set up to direct output to 
<PRIORITY>.package1.log logs, and com.foo.package2 to direct output to 
<PRIORITY>.package2.log logs.  I could do so individually by using 
PriorityMatchFilters.  That works fine.  However, what is the behavior 
when both of these packages exist in the same VM, and each .configure()s 
itself?  I do not want com.foo.package1 ERRORs going to 
ERROR.package2.log, for instance.  The only way I can think of to possibly 
avoid this clobbering, would be to create a custom CategoryFilter, which 
would only log messages coming from a particular category, and to 
register these on the appenders defined in the configuration files for 
each category.  In this manner, I would, theoretically, be able to keep 
separate ERROR.package1.log and ERROR.package2.log, etc. (as long as I keep 
appender names distinct??).

Is this the "correct" way?  Is this the only way?  Is there any better 
ways to differentiate logging output based on category?

Thanks for any feedback,
Aaron Hamid
Cornell University