dev@glassfish.java.net

Re: Please remember to wrap logger.finest calls

From: Lloyd Chambers <Lloyd.Chambers_at_Sun.COM>
Date: Fri, 11 Sep 2009 11:48:09 -0700

Another technique is to use a local varargs method and instead of
using concatenation use varargs, with the check for logging level
inside the method.

The still costs calling a method, but at least a whole bunch of
strings are not being created.

Lloyd

On Sep 11, 2009, at 11:54 AM, Kedar Mhaswade wrote:

> Jan Luehe wrote:
>> I am seeing several places in the GlassFish v3 code where logging
>> at FINEST level
>> is not wrapped inside "if (logger.isLoggable(Level.FINEST))".
>> For example (in monitoring):
>> logger.finest(
>> "[TM]requestStartEvent Unprocessed received - virtual-server
>> = " +
>> request.getServerName() + ":" + request.getServerPort() +
>> ": application = " + request.getContextPath() +
>> " : servlet = " + request.getServletPath() +
>> " : Expecting (vsName, appName) = (" +
>> virtualServerName + ", " + moduleName + ")");
>> This will cause the logging message to be assembled even at the
>> default INFO level, where it won't be logged!
>> Please remember to wrap, as follows:
>> if (logger.isLoggable(Level.FINEST)) {
>> logger.finest(...);
>> }
>
> Great point, Jan!
>
> Does anyone know if Findbugs catches these?
>
>> Thanks!
>> Jan
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>

Lloyd Chambers
lloyd.chambers_at_sun.com
GlassFish Team