You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Vic <vi...@friendvu.com> on 2005/01/21 23:47:54 UTC
Re: [Proposal] Use UGLI as logging abstraction (Re: [RT] Logging
Ceki Gülcü wrote:
>
> Torsten,
>
> We have noticed that over 95% of log statements have zero, one or two
> parameters.
Fine.
> Thus, instead of writing
>
> if(logger.isDebugEnabled() {
> logger.debug("New temperature is "+newT+" degrees");
> }
>
> you can write
>
> logger.debug("New temperature is {} degrees", newT);
If you can help me understand why are those 2 the same?
The 2nd statment does if somehow? It would not evaluate newT and String
concat?
.V
--
RiA-SoA w/JDNC <http://www.SandraSF.com> forums
- help develop a community
My blog <http://www.sandrasf.com/adminBlog>
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
Re: [Proposal] Use UGLI as logging abstraction (Re: [RT]
Logging
Posted by Ceki Gülcü <ce...@qos.ch>.
At 12:24 AM 1/22/2005, Vic wrote:
>Curt Arnold wrote:
>
>> the implementation of Logger.debug(Object, Object) would check
>> isDebugEnabled() before attempting to expand the template.
>Ah... thx! That's what I was after and it works the way I (and maybe
>others ) have been extending it.
And it only took 28 messages to get the point across. :-)
>.V
--
Ceki Gülcü
The complete log4j manual: http://www.qos.ch/log4j/
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
Re: [Proposal] Use UGLI as logging abstraction (Re: [RT] Logging
Posted by Vic <vi...@friendvu.com>.
Curt Arnold wrote:
> the implementation of Logger.debug(Object, Object) would check
> isDebugEnabled() before attempting to expand the template.
>
Ah... thx! That's what I was after and it works the way I (and maybe
others ) have been extending it.
.V
--
RiA-SoA w/JDNC <http://www.SandraSF.com> forums
- help develop a community
My blog <http://www.sandrasf.com/adminBlog>
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
Re: [Proposal] Use UGLI as logging abstraction (Re: [RT] Logging
Posted by Curt Arnold <ca...@apache.org>.
On Jan 21, 2005, at 4:47 PM, Vic wrote:
>> Thus, instead of writing
>>
>> if(logger.isDebugEnabled() {
>> logger.debug("New temperature is "+newT+" degrees");
>> }
>>
>> you can write
>>
>> logger.debug("New temperature is {} degrees", newT);
>
>
> If you can help me understand why are those 2 the same?
> The 2nd statment does if somehow? It would not evaluate newT and
> String concat?
>
They are not precisely the same, but they are roughly equivalent in
performance. When isDebugEnabled() == false, the first form evaluates
isDebugEnabled and skips over the log statement avoiding the cost of
evaluating "New temperature is "+newT+" degrees".
The second form would call logger.debug(Object, Object), so would incur
the cost of a function call regardless of whether debug is enabled, but
the implementation of Logger.debug(Object, Object) would check
isDebugEnabled() before attempting to expand the template.
So you have:
logger.debug("New temperature is " + newT + "degrees");
cost when debug disabled: method call overhead + string concatentation
overhead
cost when debug enabled: method call overhead + string concatentation
overhead + appender costs
if (logger.isDebugEnabled()) {
logger.debug("New temperature is " + newT + "degrees");
}
cost when debug disabled: logger.isDebugEnabled() evaluation + jump
cost when debug enabled: logger.isDebugEnabled() evaluation + method
call overhead + string concatentation overhead + appender costs
logger.debug("New temperature is {} degrees", newT)
cost when debug disabled: method call overhead + evaluation of
isDebugEnabled() within logger.debug + jump
cost when debug enabled: method call overhead + evaluation of
isDebugEnabled() + template expansion + appender costs
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org