At 05:38 PM 6/7/2004, you wrote:
Hi,
I have a library with a small number of public methods, every method
carrying a "client application id" parameter.
The number of different client ids can be between 3 and 10, no more.
I'd like to be able to set different logging levels for each client id.
My first guess was to set up parallel hierarchies like
- client1.com.wombat.clazz
- client2.com.wombat.clazz
so that I can set log4j.logger.client1=DEBUG and log4j.logger.client2=INFO
but I'm afraid that would impact performance negatively as I would have to
call getLogger in each method call to retrieve the right logger for the
request's client id.
No need to call getLogger() each time your methods are called. You can
place the different loggers namely logger3, logger4, ..., logger10 in a
HashMap (or even a Vector) and retrieve them from the HashMap. If a logger
is not in the HashMap only then do you call getLogger().
Has anyone faced this problem before and found a better approach?
The solution outlined above should work very well for the finite and
delimited problem you describe.
--
Ceki Gülcü
For log4j documentation consider "The complete log4j manual"
ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp