Well if you do the second part: private static final boolean DEBUG_ENABLED = LOG.isDebugEnabled();
then if you want to change your logging set-up you need to re-start the vm. Not great in an app-server or web-server environment. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: 16 January 2004 17:33 To: Log4J Users List Subject: Re: Absolute performance 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
