logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Curt Arnold <carn...@apache.org>
Subject Re: method level logger, possible?
Date Thu, 11 Oct 2007 22:34:37 GMT

On Oct 11, 2007, at 4:36 PM, Matthew Kemp wrote:

> @Curt
>
> Is the initial call to Logger.getLogger("foo") expensive or is  
> every call to
> Logger.getLogger("foo") expensive?
>

Each call at least involves a Hashtable.get() call which would  
involve a block on a mutex and hash table lookup.  The first call  
would also have additional overhead for creating and inserting the  
node in the hierarchy.  Depends on the rest of the method if that is  
proportionately expensive or cheap.

If you have a function that is called frequently and where the log  
requests do not typically satisfy the threshold, then it could be  
highly beneficial to get the logger once and use it repeatedly.  If  
you have a function that is not called frequently or where most of  
the log requests do satisfy the threshold or the method is time  
consuming, then the proportional cost of the Logger.getLogger() call  
might be inconsequential.

---------------------------------------------------------------------
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