On 20/04/17 12:25, Hoa Phan wrote:
> Hi,
> 
> I've been wondering if the condition guarding log statement in tomcat src
> like:
> 
> if (log.isDebugEnabled()) log.debug("[4] Backup becoming primary");
> 
> 
> Is it on purpose, for performance sake or just legacy code.
> 
> Would the string inside get GC or st?

Generally, that construct is for performance since creating the debug
message is much more expensive (particularly as soon as you use i18n for
all your log messages) than the isDebugEnabled() test.

For the specific example you quoted, it won't matter very much but I
still prefer that style because:

a) it means the logging code is consistent throughout the code base

b) if / when it is changed to use a more complex logging message we
don't need to remember to add the test.

Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to