<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments for Mediasoft</title>
	<atom:link href="http://blog.mediasoft.be/comments/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.mediasoft.be</link>
	<description>Enterprise Java Software Development</description>
	<lastBuildDate>Wed, 10 Jun 2009 06:48:37 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>Comment on Don&#8217;t clutter your code with isDebugEnabled by FoX</title>
		<link>http://blog.mediasoft.be/dont-clutter-your-code-with-isdebugenabled/comment-page-1/#comment-216</link>
		<dc:creator>FoX</dc:creator>
		<pubDate>Wed, 10 Jun 2009 06:48:37 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mediasoft.be/?p=51#comment-216</guid>
		<description>That&#039;s really the point in using the slf4j api, you don&#039;t have to concatenate &lt;code&gt;String&lt;/code&gt;s unnecessarily.

I&#039;ve performed some tests on the different approaches and it is clear that the overhead of using the slf4j API is minimal. Slf4j is only 16% slower than the &lt;code&gt;isDebugEnabled&lt;/code&gt; approach when debug logging is turned off (Plain Log4J is about +15000% slower), so we are talking about a performance penalty of only 0,11ms on 1000 log statements. When debug logging is turned on, the slf4j approach is only 6.50% slower than using &lt;code&gt;isDebugEnabled&lt;/code&gt;.

I&#039;d choose for cleaner code and better readability than this minor performance impact. There are other points to worry about concerning performance, like database, business logic, sorting, pagination, etc.</description>
		<content:encoded><![CDATA[<p>That&#8217;s really the point in using the slf4j api, you don&#8217;t have to concatenate <code>String</code>s unnecessarily.</p>
<p>I&#8217;ve performed some tests on the different approaches and it is clear that the overhead of using the slf4j API is minimal. Slf4j is only 16% slower than the <code>isDebugEnabled</code> approach when debug logging is turned off (Plain Log4J is about +15000% slower), so we are talking about a performance penalty of only 0,11ms on 1000 log statements. When debug logging is turned on, the slf4j approach is only 6.50% slower than using <code>isDebugEnabled</code>.</p>
<p>I&#8217;d choose for cleaner code and better readability than this minor performance impact. There are other points to worry about concerning performance, like database, business logic, sorting, pagination, etc.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Don&#8217;t clutter your code with isDebugEnabled by Vinod</title>
		<link>http://blog.mediasoft.be/dont-clutter-your-code-with-isdebugenabled/comment-page-1/#comment-215</link>
		<dc:creator>Vinod</dc:creator>
		<pubDate>Wed, 10 Jun 2009 04:50:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mediasoft.be/?p=51#comment-215</guid>
		<description>Without isDebungEnabled() code may look prettier but you have to pay the performance price. isDebugEnabled() takes far less time then a String construction for logging.</description>
		<content:encoded><![CDATA[<p>Without isDebungEnabled() code may look prettier but you have to pay the performance price. isDebugEnabled() takes far less time then a String construction for logging.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Don&#8217;t clutter your code with isDebugEnabled by rainwebs</title>
		<link>http://blog.mediasoft.be/dont-clutter-your-code-with-isdebugenabled/comment-page-1/#comment-214</link>
		<dc:creator>rainwebs</dc:creator>
		<pubDate>Tue, 09 Jun 2009 23:32:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mediasoft.be/?p=51#comment-214</guid>
		<description>The question to me is, do we really have a performance problem if the skip the if statement? The JVM optimization features and the faster processors let me tend to skip it for a better readability of the code.</description>
		<content:encoded><![CDATA[<p>The question to me is, do we really have a performance problem if the skip the if statement? The JVM optimization features and the faster processors let me tend to skip it for a better readability of the code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Don&#8217;t clutter your code with isDebugEnabled by LCB</title>
		<link>http://blog.mediasoft.be/dont-clutter-your-code-with-isdebugenabled/comment-page-1/#comment-213</link>
		<dc:creator>LCB</dc:creator>
		<pubDate>Tue, 09 Jun 2009 16:06:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mediasoft.be/?p=51#comment-213</guid>
		<description>Or, you can just set the Log4J config to not log at the debug level, but rather at a higher level. IIRC, you can define your own levels - but I haven&#039;t tried that.</description>
		<content:encoded><![CDATA[<p>Or, you can just set the Log4J config to not log at the debug level, but rather at a higher level. IIRC, you can define your own levels &#8211; but I haven&#8217;t tried that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Don&#8217;t clutter your code with isDebugEnabled by Eugene Kuleshov</title>
		<link>http://blog.mediasoft.be/dont-clutter-your-code-with-isdebugenabled/comment-page-1/#comment-212</link>
		<dc:creator>Eugene Kuleshov</dc:creator>
		<pubDate>Tue, 09 Jun 2009 15:43:20 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mediasoft.be/?p=51#comment-212</guid>
		<description>FoX, like I said, in some cases it won&#039;t be ignorable. I am quite certain that isDebugEnabled() call can be inlined by the hotspot compiler, while debug() call will be too large to inline, hence cause the overhead.</description>
		<content:encoded><![CDATA[<p>FoX, like I said, in some cases it won&#8217;t be ignorable. I am quite certain that isDebugEnabled() call can be inlined by the hotspot compiler, while debug() call will be too large to inline, hence cause the overhead.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Don&#8217;t clutter your code with isDebugEnabled by FoX</title>
		<link>http://blog.mediasoft.be/dont-clutter-your-code-with-isdebugenabled/comment-page-1/#comment-211</link>
		<dc:creator>FoX</dc:creator>
		<pubDate>Tue, 09 Jun 2009 13:42:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mediasoft.be/?p=51#comment-211</guid>
		<description>@Eugene: The performance aspect of the log method is ignorable in this case, but the size() method would still be called. I guess making the examples more realistic would be better. Let&#039;s say we would like to add some logging for auditing reasons, like the following statement:
&lt;code&gt;logger.debug(&quot;User &#039;{}&#039; altered entity &#039;{}&#039; on {}.&quot;, user, entity, date);&lt;/code&gt;
The &lt;code&gt;toString()&lt;/code&gt; of the objects won&#039;t be called in this case and the code will be more readable than using the &lt;code&gt;isDebugEnabled()&lt;/code&gt; construction.</description>
		<content:encoded><![CDATA[<p>@Eugene: The performance aspect of the log method is ignorable in this case, but the size() method would still be called. I guess making the examples more realistic would be better. Let&#8217;s say we would like to add some logging for auditing reasons, like the following statement:<br />
<code>logger.debug("User '{}' altered entity '{}' on {}.", user, entity, date);</code><br />
The <code>toString()</code> of the objects won&#8217;t be called in this case and the code will be more readable than using the <code>isDebugEnabled()</code> construction.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Don&#8217;t clutter your code with isDebugEnabled by Caligula</title>
		<link>http://blog.mediasoft.be/dont-clutter-your-code-with-isdebugenabled/comment-page-1/#comment-210</link>
		<dc:creator>Caligula</dc:creator>
		<pubDate>Tue, 09 Jun 2009 13:26:10 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mediasoft.be/?p=51#comment-210</guid>
		<description>But list.size() and user.getName() will still be called: trivial in this case, but if they were expensive you&#039;d *still* have to wrap it in an isDebugEnabled().</description>
		<content:encoded><![CDATA[<p>But list.size() and user.getName() will still be called: trivial in this case, but if they were expensive you&#8217;d *still* have to wrap it in an isDebugEnabled().</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Don&#8217;t clutter your code with isDebugEnabled by Eugene Kuleshov</title>
		<link>http://blog.mediasoft.be/dont-clutter-your-code-with-isdebugenabled/comment-page-1/#comment-209</link>
		<dc:creator>Eugene Kuleshov</dc:creator>
		<pubDate>Tue, 09 Jun 2009 13:25:17 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mediasoft.be/?p=51#comment-209</guid>
		<description>On a performance critical path it is still better to write:

if(logger.isDebugEnabled()) {
  logger.debug(&quot;The size is &#039;{}&#039;, for &#039;{}&#039;.&quot;, list.size(), user.getName());
}

because call to the log method is going to be more expensive.</description>
		<content:encoded><![CDATA[<p>On a performance critical path it is still better to write:</p>
<p>if(logger.isDebugEnabled()) {<br />
  logger.debug(&#8220;The size is &#8216;{}&#8217;, for &#8216;{}&#8217;.&#8221;, list.size(), user.getName());<br />
}</p>
<p>because call to the log method is going to be more expensive.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Don&#8217;t clutter your code with isDebugEnabled by FoX</title>
		<link>http://blog.mediasoft.be/dont-clutter-your-code-with-isdebugenabled/comment-page-1/#comment-208</link>
		<dc:creator>FoX</dc:creator>
		<pubDate>Tue, 09 Jun 2009 13:04:17 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mediasoft.be/?p=51#comment-208</guid>
		<description>@Ceki, @Bhima: You are correct, I&#039;ve changed the examples to be more trustworthy.</description>
		<content:encoded><![CDATA[<p>@Ceki, @Bhima: You are correct, I&#8217;ve changed the examples to be more trustworthy.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Don&#8217;t clutter your code with isDebugEnabled by Bhima</title>
		<link>http://blog.mediasoft.be/dont-clutter-your-code-with-isdebugenabled/comment-page-1/#comment-207</link>
		<dc:creator>Bhima</dc:creator>
		<pubDate>Tue, 09 Jun 2009 12:48:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mediasoft.be/?p=51#comment-207</guid>
		<description>Regarding the case :
logger.debug(String.format(&quot;The size is &#039;%s&#039;, for &#039;%s&#039;.&quot;, list.size(), user.getName()));

Doesn&#039;t this suffer from the same problem that normal log4j logging suffers from?  The String.format method will be always be executed regardless of what the debug level is.</description>
		<content:encoded><![CDATA[<p>Regarding the case :<br />
logger.debug(String.format(&#8220;The size is &#8216;%s&#8217;, for &#8216;%s&#8217;.&#8221;, list.size(), user.getName()));</p>
<p>Doesn&#8217;t this suffer from the same problem that normal log4j logging suffers from?  The String.format method will be always be executed regardless of what the debug level is.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
