logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bender Heri" <HBen...@Ergonomics.ch>
Subject RE: Appender per Thread (rootLogger contention)
Date Tue, 16 Aug 2005 09:42:34 GMT
Hi

Using an own written RepositorySelector is a reasonably way of having different logger universes
within the same JVM. Using the standard selector returns always the same logger instance for
a given name, since it it is stored within the unique default repository. A self written selector
which want to provied different repositories in different contexts must have some criterias
to distinguish this context at the moment when a client requests a logger. If the differentiation
can be done by different thread contexts it will be easy. You can use the MDC to store one
ore more key ("key=value") words. The MDC is kept per thread basis, so each thread can have
its own content of the key words. Your selector returns then the proper repository depending
on these context information.
 

Heri

> -----Original Message-----
> From: Iyad Elian [mailto:iyadelian@gmail.com]
> Sent: Saturday, July 23, 2005 4:28 AM
> To: log4j-user@logging.apache.org
> Subject: Appender per Thread (rootLogger contention)
> 
> 
> Our application starts with a file appender attached to the 
> rootLogger.
> The application executes different commands and some of these commands
> request that log be redirected to a separate file for the duration of
> the execution of that command. commands that don't specify a 
> logfile use
> the original appender. The master logfile looks like this:
> INFO - STARTING command: LogTest
> INFO - Redirecting command log output to: /logs/logtest.log
> INFO - FINISHED command: LogTest [status=0,elapsed_time(secs)=0]
> 
> works well, except when multiple threads execute commands 
> concurrently.
> The implementation gets the rootLogger and removes the 
> original appender
> and adds the command specific appender, executes the command then
> restores the original appender by removing the command appender and
> adding the original appender. obviously this won't work if multiple
> threads execute the same code but we couldn't figure out a better way.
> is there a way like using a RepositorySelector?
> 
> your help is appreciated.
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message