Jordi,
This is exactly what I'm doing right now, and it works great!
My situation is a bit different. In my case, I don't like the
idea of log-levels, so I've replaced it with log-types, each of which is
totally independent of the others. In my code, I simply instantiate
(statically) the logging types that I want to use and then use them as
needed. And in my config file, I simply define each one as you have
"guessed" in your original email.
Now in my case, I don't actually use the DEBUG vs INFO values, I
only use OFF & ALL, but the structure is the same. Oh, and another
difference is that I choose the logger that I want to use directly in the
code, whereas you would need to find it when the method is called. Perhaps
something as simple as an array, if the valid ids are really between 3 & 10
as you say. Or, if you meant that there will be 3 - 10 unknown ids, you'll
probably need something like a hash to look them up efficiently each time
your method is called.
Good luck.
--- regards ---
Larry
At 08:38 AM 6/7/04, 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.
Has anyone faced this problem before and found a better approach?