Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Tomcat Users »

Re: How to measue performance? Log4j on/off.

Ben Souther

2003-12-04

Replies:

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: tomcat-user-unsubscribe@(protected)
> For additional commands, e-mail: tomcat-user-help@(protected)

--
Ben Souther
F.W. Davison & Company, Inc.



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)



©2008 junlu.com - Jax Systems, LLC, U.S.A.