Howdy,
The whole point was to change at runtime without recompiling.  This is
what lgo4j allows you to do.

As to my order of magnitude improvement by using
if(logger.isDebugEnabled()) -- it's well-proven and benchmarked in the
log4j documentation, and the log4j kit comes with the benchmarks you can
run yourself.

Finally, even the example with debug("x") vs. debug(translate("x"))
missed something -- the possibly complex configuration of log4j.  If,
for example, you have an appender such as JMS, Telnet, or SMTP (all come
with log4j) configured to send out debug messages, every call to debug
can be much much more expensive than simply writing a text string to a
file.

Yoav Shapira
Millennium ChemInformatics


>-----Original Message-----
>From: Ben Souther [mailto:[EMAIL PROTECTED]
>Sent: Thursday, December 04, 2003 9:33 AM
>To: Tomcat Users List
>Subject: Re: How to measue performance? Log4j on/off.
>
>There is a hack to accomplish similar results.
>
>If you declare a constant boolean variable as false and use it in your
>branch
>statement the compiler will exclude the entire statement.
>
>static final boolean DEBUG = false;
>
>if(DEBUG){
>       //conditional code goes here
>}
>
>
>
>
>
>
>
>
>On Thursday 04 December 2003 09:05 am, Graham Reeds wrote:
>> As an aside, make sure you have all log4j Logger#debug statements
>> enclosed in if(logger.isDebugEnabled()) { ... } clauses -- that's an
>> order of magnitude or so runtime performance improvement.
>>
>>
>> Showing my C heritage here, but can't you do something like
>>
>> Log("an error has occurred");
>>
>> And in Log have a directive like
>>
>> class Logger()
>> {
>>     void Log(string msg)
>>     {
>> #ifdef DEBUG
>>         ... log message ..
>> #endif
>> };
>>
>> And so you can compile a version with debug or no debug.  Those if()
>> statements are still going to take time to process, even if there is
no
>> logging going on.
>>
>> G.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>
>--
>Ben Souther
>F.W. Davison & Company, Inc.
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]




This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to