logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jacob Kjome" <h...@visi.com>
Subject Re: LogManager / LoggerRepository
Date Fri, 17 Feb 2012 16:53:21 GMT

It's not clear what problem you are trying to solve?  When you call 
Logger.getLogger("blah"), if "blah" Logger does not yet exist, it is created.  
If it does exist it is returned.  Loggers are stored in a LoggerRepository.  
How many logger repositories there are depends upon logger repository 
implementation behavior and/or classloading behavior as well as where you 
place log4j.jar in your container's classpath.

For instance, if you place log4j.jar in WEB-INF/lib and use child-first 
classloading (ensuring that WEB-INF/lib/log4j.jar gets used rather than one 
found in a parent classloader), then you will have on "blah" Logger for that 
webapp.  If you have another webapp containing log4j.jar and a common library 
using "blah" Logger, it will have its own independent instance of "blah" 
Logger.  So, you will have 2 "blah" Loggers under the same appserver.

Let's say you have the same scenario, except you don't include log4j.jar in 
WEB-INF/lib, but in some parent classloader available to both webapps.  Now 
you will have a single "blah" Logger rather than 2.

There are more scenarios, but I'll stop there.  You might also want to 
read....

http://wiki.apache.org/logging-log4j/AppContainerLogging


Is that helpful?

Jake

On Fri, 17 Feb 2012 01:51:16 -0800 (PST)
 indomie15 <suigion.anderson@gmail.com> wrote:
> 
> Hi all,
> 
> I am using log4j-1.2.8.jar in my application.
> How do I manage my Logger object? the number of logger object will be
> created everytime it is access by application.
> 
> Is there a way to create the logger object one time and subsequently the
> created logger object will be used by the application?
> 
> I google search and came across this "LoggerRepository" and LogManager". How
> to use these two components? 
> 
> Thank you.
> 
> Anderson
> -- 
> View this message in context: 
>http://old.nabble.com/LogManager---LoggerRepository-tp33341582p33341582.html
> Sent from the Log4j - Users mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> 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