There is no problem with using final with the logger as I see no reason 
why you would want to obtain
another logger instance post class initialization. 

However, using a final boolean for the DEBUG flag would prevent the class 
from detecting any run time 
changes to the classes's level during the lifetime of the VM.  log4j 
does/can detect changes to the 
configuration at anytime during the lifespan of the VM.

<[EMAIL PROTECTED]> wrote on 16/01/2004 17:33:26:

> I always spot my mistakes that moment after hitting send - of course
> it should be -
> 
> private static final Logger LOG = Logger.getLogger(MyClass.class);
> private static final boolean DEBUG_ENABLED = LOG.isDebugEnabled();
> 
> > 
> > From: <[EMAIL PROTECTED]>
> > Date: 2004/01/16 Fri PM 05:30:29 GMT
> > To: [EMAIL PROTECTED]
> > Subject: Absolute performance
> > 
> > While with my mind on some unrelated performance issues in a 
> project I scanned through some tips in 
http://www.javaperformancetuning.com
> > 
> > The ones in http://www.javaperformancetuning.com/tips/final.shtml 
> made me think that maybe the best logger definition whould be -
> > 
> > private static final LOG = Logger.getLogger(MyClass.class);
> > 
> > I quote - 
> > "Generally, I wouldn't go out of my way to declare a method or 
> class final purely for performance reasons. Only after you've 
> definitely identified a performance problem is this even worth 
considering. 
> > On the other hand, final variables, especially static final 
> variables, are well worth using as standard."
> > 
> > A tip further down for another logging system would suggest that 
> for log4j even better performance could be gained by using both -
> > 
> > private static final LOG = Logger.getLogger(MyClass.class);
> > private static final DEBUG_ENABLED = LOG.isDebugEnabled();
> > 
> > Then in code it would be
> > 
> >     if (DEBUG_ENABLED) LOG.debug("Hello Logging World");
> > 
> > Is there any reason why this is not already suggested on the log4j
> website. Is there any circumstance for which it wouldn't be recommended?
> > 
> > Bob.
> > 
> > 
> > -----------------------------------------
> > Email provided by http://www.ntlhome.com/
> > 
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> > 
> 
> -----------------------------------------
> Email provided by http://www.ntlhome.com/
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> ________________________________________________________________________
> This e-mail has been scanned for all viruses by Star Internet. The
> service is powered by MessageLabs. For more information on a proactive
> anti-virus service working around the clock, around the globe, visit:
> http://www.star.net.uk
> ________________________________________________________________________
> 


________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Reply via email to