commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rodney Waldhoff <rwaldh...@apache.org>
Subject Re: [logging] logic for determing log level
Date Thu, 30 Oct 2003 22:30:06 GMT
Assuming the if() clause isn't there, then:

  "Is " + descriptor + " empty?"

is evaluated before the call to log.trace(), whether or not that call will
actually yield any output.  Putting the if() { } around it prevents the
arguments to log.trace() from being executed if log.isTraceEnabled() is
false.

See
<http://jakarta.apache.org/log4j/docs/api/org/apache/log4j/Category.html#isDebugEnabled()>
for example.

On Thu, 30 Oct 2003, __matthewHawthorne wrote:

> This is a general use question about [logging].  I'm looking through the
> source for [betwixt], and I see lines like the following:
>
> if ( log.isTraceEnabled() ) {
>    log.trace( "Is " + descriptor + " empty?" );
> }
>
> What is the purpose of doing this check?  If trace *is* enabled, then
> isn't the same check done inside of the underlying logging implementation?
>
> Is this some type of trick to improve performance?  I'm probably
> misunderstanding it, but I just think that it adds clutter.
>
> Any insights?
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>

-- 
- Rod <http://radio.weblogs.com/0122027/>

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message