<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.3" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Why You Should Use &#8220;isDebugEnabled&#8221; ?</title>
	<link>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/</link>
	<description>New SMS Library at http://twit88.com/platform/projects/show/messagingtoolkit !</description>
	<pubDate>Mon, 15 Mar 2010 09:28:45 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
		<item>
		<title>By: Tech Per</title>
		<link>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/#comment-19680</link>
		<dc:creator>Tech Per</dc:creator>
		<pubDate>Tue, 30 Sep 2008 14:41:08 +0000</pubDate>
		<guid>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/#comment-19680</guid>
		<description>@Suresh:

Yep. Take a look at http://www.nelz.net/roller/nelz/entry/log4j_runtime_configuration</description>
		<content:encoded><![CDATA[<p>@Suresh:</p>
<p>Yep. Take a look at <a href="http://www.nelz.net/roller/nelz/entry/log4j_runtime_configuration" rel="nofollow">http://www.nelz.net/roller/nelz/entry/log4j_runtime_configuration</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Suresh</title>
		<link>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/#comment-19665</link>
		<dc:creator>Suresh</dc:creator>
		<pubDate>Tue, 30 Sep 2008 12:13:29 +0000</pubDate>
		<guid>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/#comment-19665</guid>
		<description>How can I disable log at runtime. I am using log4j.xml file. I am able to generate the logs successfully. But now i would like to on and off this feature. Is there any way to enable and disable the generating logs.</description>
		<content:encoded><![CDATA[<p>How can I disable log at runtime. I am using log4j.xml file. I am able to generate the logs successfully. But now i would like to on and off this feature. Is there any way to enable and disable the generating logs.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 547e44d7969d</title>
		<link>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/#comment-7778</link>
		<dc:creator>547e44d7969d</dc:creator>
		<pubDate>Sat, 10 May 2008 16:00:27 +0000</pubDate>
		<guid>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/#comment-7778</guid>
		<description>&lt;strong&gt;547e44d7969d...&lt;/strong&gt;

547e44d7969dc7fb2ebf...</description>
		<content:encoded><![CDATA[<p><strong>547e44d7969d&#8230;</strong></p>
<p>547e44d7969dc7fb2ebf&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: satish</title>
		<link>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/#comment-7586</link>
		<dc:creator>satish</dc:creator>
		<pubDate>Thu, 08 May 2008 09:15:14 +0000</pubDate>
		<guid>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/#comment-7586</guid>
		<description>I tried doing this, as a good practice. But I see that it increases clutter a lot. I am back to plain old log.debug in most cases. I now check isDebugEnabled only when a toString operation is costly in terms of time.</description>
		<content:encoded><![CDATA[<p>I tried doing this, as a good practice. But I see that it increases clutter a lot. I am back to plain old log.debug in most cases. I now check isDebugEnabled only when a toString operation is costly in terms of time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jim LoVerde</title>
		<link>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/#comment-4624</link>
		<dc:creator>Jim LoVerde</dc:creator>
		<pubDate>Mon, 24 Mar 2008 06:16:40 +0000</pubDate>
		<guid>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/#comment-4624</guid>
		<description>Actually, the approach taken by log5j (a wrapper around log4j) offer a much more elegant solution.
http://code.google.com/p/log5j/

Basically, instead of using:

if (log.isDebugEnabled()) 
  log.debug("variable A is set to " + myVariableA);

You take advantage of JDK 1.5 syntax and write:

log.debug("variable A is set to %s", myVariableA);

Notice that you still get the benefit of not having the String concatenation taking place unless debug is enabled, but now you don't have to clutter your code with a bunch of if statements.</description>
		<content:encoded><![CDATA[<p>Actually, the approach taken by log5j (a wrapper around log4j) offer a much more elegant solution.<br />
<a href="http://code.google.com/p/log5j/" rel="nofollow">http://code.google.com/p/log5j/</a></p>
<p>Basically, instead of using:</p>
<p>if (log.isDebugEnabled())<br />
  log.debug(&#8221;variable A is set to &#8221; + myVariableA);</p>
<p>You take advantage of JDK 1.5 syntax and write:</p>
<p>log.debug(&#8221;variable A is set to %s&#8221;, myVariableA);</p>
<p>Notice that you still get the benefit of not having the String concatenation taking place unless debug is enabled, but now you don&#8217;t have to clutter your code with a bunch of if statements.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Diego Parrilla</title>
		<link>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/#comment-4117</link>
		<dc:creator>Diego Parrilla</dc:creator>
		<pubDate>Tue, 11 Mar 2008 08:21:28 +0000</pubDate>
		<guid>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/#comment-4117</guid>
		<description>I used the "isDebugEnabled" recommendation early in 1999, 2000 and 2001 with java. But we stopped using it because it did not give us a lot in terms of performance using JVM 1.3. In server side development the database is the bottleneck and the 'isDebugEnabled' only makes the code less clear. 
I think this is an old fashion tip.</description>
		<content:encoded><![CDATA[<p>I used the &#8220;isDebugEnabled&#8221; recommendation early in 1999, 2000 and 2001 with java. But we stopped using it because it did not give us a lot in terms of performance using JVM 1.3. In server side development the database is the bottleneck and the &#8216;isDebugEnabled&#8217; only makes the code less clear.<br />
I think this is an old fashion tip.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrey P.Rybin</title>
		<link>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/#comment-4116</link>
		<dc:creator>Andrey P.Rybin</dc:creator>
		<pubDate>Tue, 11 Mar 2008 08:20:59 +0000</pubDate>
		<guid>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/#comment-4116</guid>
		<description>I agree completely with lunatix.

Use http://slf4j.org as logging facade and enjoy its .debug("very fast logging (if disabled) {}", myObjWithHeavyToString)</description>
		<content:encoded><![CDATA[<p>I agree completely with lunatix.</p>
<p>Use <a href="http://slf4j.org" rel="nofollow">http://slf4j.org</a> as logging facade and enjoy its .debug(&#8221;very fast logging (if disabled) {}&#8221;, myObjWithHeavyToString)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Jablow</title>
		<link>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/#comment-4104</link>
		<dc:creator>Eric Jablow</dc:creator>
		<pubDate>Tue, 11 Mar 2008 00:29:46 +0000</pubDate>
		<guid>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/#comment-4104</guid>
		<description>If one has a business reason to do a lot of logging, one can declare an object renderer class in the log4j.xml file, and then one simply writes,

Person p = new Person("Eric", "Jablow");
// ...
LOGGER.debug(p); // Uses the declared renderer for Person.</description>
		<content:encoded><![CDATA[<p>If one has a business reason to do a lot of logging, one can declare an object renderer class in the log4j.xml file, and then one simply writes,</p>
<p>Person p = new Person(&#8221;Eric&#8221;, &#8220;Jablow&#8221;);<br />
// &#8230;<br />
LOGGER.debug(p); // Uses the declared renderer for Person.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tech Per</title>
		<link>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/#comment-4100</link>
		<dc:creator>Tech Per</dc:creator>
		<pubDate>Mon, 10 Mar 2008 19:57:40 +0000</pubDate>
		<guid>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/#comment-4100</guid>
		<description>I agree completely with Jim.

I, myself, used to wrap my log.debug statements in an isDebugEnabled() call. I don't anymore. In most, if not nearly all, applications of today, the performance gain will negligible and next to nothing.

I will *much* rather put my emphasis on clearer code, which is easier to write, than to squeezing the last nano-second out of the CPU.

In addition, the (perceived) problem of string concatenation is a hard one to kill, even though at least the last two production JVMs from Sun, have done a great job at making it go away. It was in the "old days", that this was a problem.</description>
		<content:encoded><![CDATA[<p>I agree completely with Jim.</p>
<p>I, myself, used to wrap my log.debug statements in an isDebugEnabled() call. I don&#8217;t anymore. In most, if not nearly all, applications of today, the performance gain will negligible and next to nothing.</p>
<p>I will *much* rather put my emphasis on clearer code, which is easier to write, than to squeezing the last nano-second out of the CPU.</p>
<p>In addition, the (perceived) problem of string concatenation is a hard one to kill, even though at least the last two production JVMs from Sun, have done a great job at making it go away. It was in the &#8220;old days&#8221;, that this was a problem.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jim</title>
		<link>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/#comment-4094</link>
		<dc:creator>Jim</dc:creator>
		<pubDate>Mon, 10 Mar 2008 17:16:57 +0000</pubDate>
		<guid>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/#comment-4094</guid>
		<description>This is a bad idea.  To summarize to points above:

 - It confuses the designed intent of isDebugEnabled().
 - It unnecessarily clutters up readable code.
 - The performance gain is so negligible, that 10 million repetitions are necessary to even notice it.  If you are logging &#62;10 million occurences, your logs are worthless

Further, you may not know this, but

log.debug("this is a test")

and

log.debug("this " + " is " + " a " +  " test");

generate identical bytecode.  (Try it.)</description>
		<content:encoded><![CDATA[<p>This is a bad idea.  To summarize to points above:</p>
<p> - It confuses the designed intent of isDebugEnabled().<br />
 - It unnecessarily clutters up readable code.<br />
 - The performance gain is so negligible, that 10 million repetitions are necessary to even notice it.  If you are logging &gt;10 million occurences, your logs are worthless</p>
<p>Further, you may not know this, but</p>
<p>log.debug(&#8221;this is a test&#8221;)</p>
<p>and</p>
<p>log.debug(&#8221;this &#8221; + &#8221; is &#8221; + &#8221; a &#8221; +  &#8221; test&#8221;);</p>
<p>generate identical bytecode.  (Try it.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: B. Waite</title>
		<link>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/#comment-4093</link>
		<dc:creator>B. Waite</dc:creator>
		<pubDate>Mon, 10 Mar 2008 16:24:44 +0000</pubDate>
		<guid>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/#comment-4093</guid>
		<description>I almost agree with Mark.  Almost.

Logs lose utility when you have a multithreaded application running on several machines, each processing hundreds of simultaneous user requests.   It’s like playing a combination of poker and 52-pickup at the same time--you just can't sort out the signal from the noise.

That’s why I created a batch logger.  It aggregates all calls into a batch before logging them.   This results in each request being output in one chunk.  This makes deciphering logs *much* easier.

The logger can be instructed to keep quiet unless a problem occurs, at which point it dumps the offending batch.  Our logs are generally empty, except for startup info and errors.

Finally, the batch logger can format the output as HTML.  If our app is in debug mode, the log batch is appended to the bottom of each web page.  The HTML is rendered per task, and uses JavaScript to allow us to drill down into the call stack.

The end result is that we *rarely* need to look at the logs.  If we can reproduce the error, we’ll see the details on page that caused it.</description>
		<content:encoded><![CDATA[<p>I almost agree with Mark.  Almost.</p>
<p>Logs lose utility when you have a multithreaded application running on several machines, each processing hundreds of simultaneous user requests.   It’s like playing a combination of poker and 52-pickup at the same time&#8211;you just can&#8217;t sort out the signal from the noise.</p>
<p>That’s why I created a batch logger.  It aggregates all calls into a batch before logging them.   This results in each request being output in one chunk.  This makes deciphering logs *much* easier.</p>
<p>The logger can be instructed to keep quiet unless a problem occurs, at which point it dumps the offending batch.  Our logs are generally empty, except for startup info and errors.</p>
<p>Finally, the batch logger can format the output as HTML.  If our app is in debug mode, the log batch is appended to the bottom of each web page.  The HTML is rendered per task, and uses JavaScript to allow us to drill down into the call stack.</p>
<p>The end result is that we *rarely* need to look at the logs.  If we can reproduce the error, we’ll see the details on page that caused it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ran</title>
		<link>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/#comment-4090</link>
		<dc:creator>Ran</dc:creator>
		<pubDate>Mon, 10 Mar 2008 15:45:45 +0000</pubDate>
		<guid>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/#comment-4090</guid>
		<description>@Mark: My comment wasn't directed at you. Rather, it was directed at the author of the article.
However, regarding your comment, I disagree. Debug logs are just for that - debug time. When you're working on a multi-threaded application (in an application server for example), it's very hard to follow the flow of the code without logs. However, once you've finished the debugging of a specific area - close the debug logs for that area! Not only they clutter your log file (which should, IMHO, be almost clean), but they pose a security risk (since various data is usually written to debug, including session ids, user information and even whole packets).</description>
		<content:encoded><![CDATA[<p>@Mark: My comment wasn&#8217;t directed at you. Rather, it was directed at the author of the article.<br />
However, regarding your comment, I disagree. Debug logs are just for that - debug time. When you&#8217;re working on a multi-threaded application (in an application server for example), it&#8217;s very hard to follow the flow of the code without logs. However, once you&#8217;ve finished the debugging of a specific area - close the debug logs for that area! Not only they clutter your log file (which should, IMHO, be almost clean), but they pose a security risk (since various data is usually written to debug, including session ids, user information and even whole packets).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Turansky</title>
		<link>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/#comment-4089</link>
		<dc:creator>Mark Turansky</dc:creator>
		<pubDate>Mon, 10 Mar 2008 15:36:12 +0000</pubDate>
		<guid>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/#comment-4089</guid>
		<description>No, I didn't miss the point.

I think debug statements are useless, so I wouldn't litter my code with them or with the log.isDebugEnabled call.

Your mileage may vary, but I've not seen many apps that have meaningful debug logs.</description>
		<content:encoded><![CDATA[<p>No, I didn&#8217;t miss the point.</p>
<p>I think debug statements are useless, so I wouldn&#8217;t litter my code with them or with the log.isDebugEnabled call.</p>
<p>Your mileage may vary, but I&#8217;ve not seen many apps that have meaningful debug logs.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ran</title>
		<link>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/#comment-4088</link>
		<dc:creator>Ran</dc:creator>
		<pubDate>Mon, 10 Mar 2008 15:29:39 +0000</pubDate>
		<guid>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/#comment-4088</guid>
		<description>You missed the point of isDebugEnabled().
The withCheck() method should've been written like this:
private void withCheck() {
...
if (log.isDebugEnabled())
 for (int i = 0; i &#60; 10000000; i++){
  log.debug("this is a test");
 }
}...

The point of isDebugEnabled() is to save loops and temporary object creation for debug purposes when you have no need for the debug log.</description>
		<content:encoded><![CDATA[<p>You missed the point of isDebugEnabled().<br />
The withCheck() method should&#8217;ve been written like this:<br />
private void withCheck() {<br />
&#8230;<br />
if (log.isDebugEnabled())<br />
 for (int i = 0; i &lt; 10000000; i++){<br />
  log.debug(&#8221;this is a test&#8221;);<br />
 }<br />
}&#8230;</p>
<p>The point of isDebugEnabled() is to save loops and temporary object creation for debug purposes when you have no need for the debug log.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Turansky</title>
		<link>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/#comment-4087</link>
		<dc:creator>Mark Turansky</dc:creator>
		<pubDate>Mon, 10 Mar 2008 15:27:52 +0000</pubDate>
		<guid>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/#comment-4087</guid>
		<description>&lt;a href="http://blog.markturansky.com/archives/29" rel="nofollow"&gt;Your application logging is largely useless&lt;/a&gt; and debug statement just makes for gigs of spam in a log file.  It's snowcrash, unreadable, and useless.

I say omit the debug statements entirely.</description>
		<content:encoded><![CDATA[<p><a href="http://blog.markturansky.com/archives/29" rel="nofollow">Your application logging is largely useless</a> and debug statement just makes for gigs of spam in a log file.  It&#8217;s snowcrash, unreadable, and useless.</p>
<p>I say omit the debug statements entirely.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lunatix</title>
		<link>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/#comment-4082</link>
		<dc:creator>lunatix</dc:creator>
		<pubDate>Mon, 10 Mar 2008 09:55:39 +0000</pubDate>
		<guid>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/#comment-4082</guid>
		<description>use slf4j instead of jcl, and you'll be able to write logger.debug("The new entry is {}.", entry);  the price of string concatenation is only payed if log is enable, and you don't have to write ugly bloat code like isDebugIsEnable()

@see
http://www.slf4j.org/faq.html#logging_performance</description>
		<content:encoded><![CDATA[<p>use slf4j instead of jcl, and you&#8217;ll be able to write logger.debug(&#8221;The new entry is {}.&#8221;, entry);  the price of string concatenation is only payed if log is enable, and you don&#8217;t have to write ugly bloat code like isDebugIsEnable()</p>
<p>@see<br />
<a href="http://www.slf4j.org/faq.html#logging_performance" rel="nofollow">http://www.slf4j.org/faq.html#logging_performance</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stefan</title>
		<link>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/#comment-4062</link>
		<dc:creator>Stefan</dc:creator>
		<pubDate>Sun, 09 Mar 2008 16:57:44 +0000</pubDate>
		<guid>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/#comment-4062</guid>
		<description>@jude: The whole point of adding isDebugEnabled() is not calling a method. Usually you have some string concatenations (or toString calls) in your debug statement. And you don't need that string (and the garbage for the strinbuffer etc.) when you don't print it. Thus you need to add a isDebugEnabled() before the debug statement.
Maybe thing will change when closures arrive and the evaluation of the argument for debug can be deferred.</description>
		<content:encoded><![CDATA[<p>@jude: The whole point of adding isDebugEnabled() is not calling a method. Usually you have some string concatenations (or toString calls) in your debug statement. And you don&#8217;t need that string (and the garbage for the strinbuffer etc.) when you don&#8217;t print it. Thus you need to add a isDebugEnabled() before the debug statement.<br />
Maybe thing will change when closures arrive and the evaluation of the argument for debug can be deferred.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jude</title>
		<link>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/#comment-4061</link>
		<dc:creator>jude</dc:creator>
		<pubDate>Sun, 09 Mar 2008 16:06:35 +0000</pubDate>
		<guid>http://twit88.com/blog/2008/03/07/why-you-should-use-isdebugenabled/#comment-4061</guid>
		<description>instead of having an if statement at every place inside your code wherever you plan to use the logging system , it makes more sense to put the if statement inside the debug method . A strategy could be used to poly morphically control the use of if statement</description>
		<content:encoded><![CDATA[<p>instead of having an if statement at every place inside your code wherever you plan to use the logging system , it makes more sense to put the if statement inside the debug method . A strategy could be used to poly morphically control the use of if statement</p>
]]></content:encoded>
	</item>
</channel>
</rss>
