<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:symbol;font-size:12pt"><div style="font-family: symbol; font-size: 12pt;"><span style="font-family: arial,helvetica,sans-serif;">Hello Sebastian,</span><br style="font-family: arial,helvetica,sans-serif;"><br style="font-family: arial,helvetica,sans-serif;"><span style="font-family: arial,helvetica,sans-serif;">Thanks a lot for ur replies and all the efforts that u have put in into this great product. I will surely test this new code. In ur previous reply u had asked me the source of my assumption that the parameterized call is faster then "isDebugEnabled". Well I misinterpreted the "10 reasons to use logback" slideshow that is available on the logback site .. I am pasting the contents of the slide (Slide number 21)&nbsp; that confused me, maybe u can consider rewording it - </span><br><br><p:colorscheme
 colors="#FFFFFF,#000000,#00007D,#000000,#9999FF,#9999CC,#666699,#CCCCE6">

</p:colorscheme><div v:shape="_x0000_s3074" class="O">

<div style=""><span style="font-family: &quot;Courier New&quot;; font-size: 117%;" lang="EN-US">Integer entry = new Interger(50); 
</span></div>

<div style=""><span style="font-family: &quot;Courier New&quot;; font-size: 117%;" lang="EN-US">logger.debug(</span><span style="font-family: &quot;Courier New&quot;; font-size: 117%; color: red;" lang="EN-US">"The entry is "+entry+"."</span><span style="font-family: &quot;Courier New&quot;; font-size: 117%;" lang="EN-US">);
</span></div>

<div style=""><span style="font-family: Arial; font-size: 117%;" lang="EN-US">
</span></div>

<div style=""><span style="font-family: Arial; font-size: 117%;" lang="EN-US">can be optimized as:
</span></div>

<div style=""><span style="font-family: Arial; font-size: 117%;" lang="EN-US"><span style="">&nbsp;</span></span><span style="font-family: &quot;Courier New&quot;; font-size: 117%;" lang="EN-US">if(logger.isDebugEnabled()) {
</span></div>

<div style=""><span style="font-family: &quot;Courier New&quot;; font-size: 117%;" lang="EN-US"><span style="">&nbsp;</span>logger.debug("The entry is "+entry+".");
</span></div>

<div style=""><span style="font-family: &quot;Courier New&quot;; font-size: 117%;" lang="EN-US">}
</span></div>

<div style=""><span style="font-family: &quot;Courier New&quot;; font-size: 117%;" lang="EN-US">
</span></div>

<div style=""><span style="font-family: Arial; font-size: 117%;" lang="EN-US">or better yet:</span><span style="font-family: &quot;Courier New&quot;; font-size: 117%;" lang="EN-US">
</span></div>

<div style=""><span style="font-family: &quot;Courier New&quot;; font-size: 117%;" lang="EN-US">logger.debug("The entry is </span><span style="font-family: &quot;Courier New&quot;; font-size: 117%;" lang="EN-US"><b>{}</b></span><span style="font-family: &quot;Courier New&quot;; font-size: 117%;" lang="EN-US">.", entry);<br><br>so u see that the second and third point are not actually related ...:)<br><br></span><span style="font-family: &quot;Courier New&quot;; font-size: 117%;" lang="EN-US"><br>
Also I have another small query , my project uses a mixture of commons logging and log4j, also some of the thirdparty libraries that we use, are using commons. Where does logback fit in commons ? Can u point me a doc which i can refer for the same.<br><br>once again thanks for all ur help.<br><br>regards<br>Mandeep<br></span><span style="font-family: &quot;Courier New&quot;; font-size: 117%;" lang="EN-US"><br> 
</span></div>

<div style=""><span style="font-family: Arial; font-size: 117%;" lang="EN-US">
</span></div>

<div style=""><span style="">
</span></div>

</div>

<br><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">----- Original Message ----<br>From: Sebastien Pennec &lt;sebastien@qos.ch&gt;<br>To: logback users list &lt;logback-user@qos.ch&gt;<br>Sent: Tuesday, March 13, 2007 11:41:16 AM<br>Subject: Re: [logback-user] logback performance clarification<br><br><div>Hello Mandeep,<br><br>After some research and performance optimizations, here are the results I've <br>obtained. Times are shown in nanoseconds per requests, and are an average time after <br>1'000'000 requests.<br><br>Log4j direct debug call: 442<br>Log4j tested (isDebugEnabled) debug call: 19<br>Logback direct debug call: 435<br>Logback tested (isDebugEnabled) debug call: 10<br>Logback parametrized debug call: 15<br><br>They are rather different than what I had witnessed previously.<br><br>First of all, the procedure is closer to a real life example. The <br>PerformanceComparator class is nested into a 4-level deep package, and not in
 the top <br>package. Then, only the root loggers have a level set explicitly. That means that <br>both logging frameworks have to include level inheritance when deciding to log or not.<br><br>This show how logback performs faster than log4j when relying on level inheritance. <br>The tested call (using isDebugEnabled()) in logback is almost 2 times faster than its <br>log4j counterpart.<br><br>Then, we've made a few optimizations in logback's Logger class. There are now less <br>method calls, and smarter if statements when recieving the TurboFilter's reply. This <br>has made the parametrized call much faster. This form is now faster than log4j's <br>isDebugEnabled() form.<br><br>Since TurboFilters are a big feature of logback, I should mention that they are <br>called when using the direct call or the parametrized call, but also when calling <br>isDebugEnabled(). For example, you might want to set your levels to INFO or WARN in <br>production, and add a TurboFilter that
 sets the level to DEBUG for a certain user. <br>Having the username in the MDC, you can easily add a TurboFilter that will always <br>accept the log requests when they are issued by this user's actions, although the <br>logger would not accept such requests coming from any other user.<br>The isDebugEnabled will then return false every time, except when the current user is <br>logged with the username to allow debug level.<br><br>I've attached the class I used to get these results at the end of this email. You <br>might want to try it on your environment and see if the performance satisfy your <br>needs. You will need to checkout logback from its source repository[1][2]<br><br>Cheers,<br><br>Sébastien<br><br>[1]<a target="_blank" href="http://logback.qos.ch/repos.html">http://logback.qos.ch/repos.html</a><br>[2]<a target="_blank"
 href="http://logback.qos.ch/manual/introduction.html#BuildingLogback">http://logback.qos.ch/manual/introduction.html#BuildingLogback</a><br><br>package perfTest.ch.qos.logback;<br><br>import org.slf4j.Logger;<br>import org.slf4j.LoggerFactory;<br><br>public class PerformanceComparator {<br><br>&nbsp;&nbsp; static Logger logbacklogger = LoggerFactory<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .getLogger(PerformanceComparator.class);<br>&nbsp;&nbsp; static org.apache.log4j.Logger log4jlogger = org.apache.log4j.Logger<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .getLogger(PerformanceComparator.class);<br><br>&nbsp;&nbsp; // How many times should we try to log:<br>&nbsp;&nbsp; static int loop = 1000000;<br><br>&nbsp;&nbsp; public static void main(String[] args) throws InterruptedException {<br>&nbsp;&nbsp;&nbsp;&nbsp; initConfig();<br><br>&nbsp;&nbsp;&nbsp;&nbsp; // Let's run once for Just In Time compiler<br>&nbsp;&nbsp;&nbsp;&nbsp;
 log4jDirectDebugCall();<br>&nbsp;&nbsp;&nbsp;&nbsp; log4jTestedDebugCall();<br>&nbsp;&nbsp;&nbsp;&nbsp; logbackDirectDebugCall();<br>&nbsp;&nbsp;&nbsp;&nbsp; logbackTestedDebugCall();<br>&nbsp;&nbsp;&nbsp;&nbsp; logbackParametrizedDebugCall();<br><br>&nbsp;&nbsp;&nbsp;&nbsp; // let's run the tests and display the results:<br>&nbsp;&nbsp;&nbsp;&nbsp; long result1 = log4jDirectDebugCall();<br>&nbsp;&nbsp;&nbsp;&nbsp; long result2 = log4jTestedDebugCall();<br>&nbsp;&nbsp;&nbsp;&nbsp; long result3 = logbackDirectDebugCall();<br>&nbsp;&nbsp;&nbsp;&nbsp; long result4 = logbackTestedDebugCall();<br>&nbsp;&nbsp;&nbsp;&nbsp; long result5 = logbackParametrizedDebugCall();<br><br>&nbsp;&nbsp;&nbsp;&nbsp; System.out.println("###############################################");<br>&nbsp;&nbsp;&nbsp;&nbsp; System.out.println("Log4j direct debug call: " + result1);<br>&nbsp;&nbsp;&nbsp;&nbsp; System.out.println("Log4j tested (isDebugEnabled) debug call: " +
 result2);<br>&nbsp;&nbsp;&nbsp;&nbsp; System.out.println("Logback direct debug call: " + result3);<br>&nbsp;&nbsp;&nbsp;&nbsp; System.out<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .println("Logback tested (isDebugEnabled) debug call: " + result4);<br>&nbsp;&nbsp;&nbsp;&nbsp; System.out.println("Logback parametrized debug call: " + result5);<br>&nbsp;&nbsp;&nbsp;&nbsp; System.out.println("###############################################");<br>&nbsp;&nbsp; }<br><br>&nbsp;&nbsp; private static long log4jDirectDebugCall() {<br>&nbsp;&nbsp;&nbsp;&nbsp; Integer j = new Integer(2);<br>&nbsp;&nbsp;&nbsp;&nbsp; long start = System.nanoTime();<br>&nbsp;&nbsp;&nbsp;&nbsp; for (int i = 0; i &lt; loop; i++) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; log4jlogger.debug("SEE IF THIS IS LOGGED " + j + ".");<br>&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp; return (System.nanoTime() - start) / loop;<br>&nbsp;&nbsp; }<br><br>&nbsp;&nbsp; private static long
 log4jTestedDebugCall() {<br>&nbsp;&nbsp;&nbsp;&nbsp; Integer j = new Integer(2);<br>&nbsp;&nbsp;&nbsp;&nbsp; long start = System.nanoTime();<br>&nbsp;&nbsp;&nbsp;&nbsp; for (int i = 0; i &lt; loop; i++) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (log4jlogger.isDebugEnabled()) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; log4jlogger.debug("SEE IF THIS IS LOGGED " + j + ".");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp; return (System.nanoTime() - start) / loop;<br>&nbsp;&nbsp; }<br><br>&nbsp;&nbsp; private static long logbackDirectDebugCall() {<br>&nbsp;&nbsp;&nbsp;&nbsp; Integer j = new Integer(2);<br>&nbsp;&nbsp;&nbsp;&nbsp; long start = System.nanoTime();<br>&nbsp;&nbsp;&nbsp;&nbsp; for (int i = 0; i &lt; loop; i++) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; logbacklogger.debug("SEE IF THIS IS LOGGED " + j + ".");<br>&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp; return (System.nanoTime() - start) /
 loop;<br>&nbsp;&nbsp; }<br><br>&nbsp;&nbsp; private static long logbackTestedDebugCall() {<br>&nbsp;&nbsp;&nbsp;&nbsp; Integer j = new Integer(2);<br>&nbsp;&nbsp;&nbsp;&nbsp; long start = System.nanoTime();<br>&nbsp;&nbsp;&nbsp;&nbsp; for (int i = 0; i &lt; loop; i++) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (logbacklogger.isDebugEnabled())<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; logbacklogger.debug("SEE IF THIS IS LOGGED " + j + ".");<br>&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp; return (System.nanoTime() - start) / loop;<br>&nbsp;&nbsp; }<br><br>&nbsp;&nbsp; private static long logbackParametrizedDebugCall() {<br>&nbsp;&nbsp;&nbsp;&nbsp; Integer j = new Integer(2);<br>&nbsp;&nbsp;&nbsp;&nbsp; long start = System.nanoTime();<br>&nbsp;&nbsp;&nbsp;&nbsp; for (int i = 0; i &lt; loop; i++) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; logbacklogger.debug("SEE IF THIS IS LOGGED {}.", j);<br>&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp; return
 (System.nanoTime() - start) / loop;<br>&nbsp;&nbsp; }<br><br>&nbsp;&nbsp; private static void initConfig() {<br>&nbsp;&nbsp;&nbsp;&nbsp; org.apache.log4j.Logger log4jRoot = org.apache.log4j.Logger.getRootLogger();<br>&nbsp;&nbsp;&nbsp;&nbsp; log4jRoot.setLevel(org.apache.log4j.Level.INFO);<br><br>&nbsp;&nbsp;&nbsp;&nbsp; ch.qos.logback.classic.Logger lbRoot = (ch.qos.logback.classic.Logger) LoggerFactory<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .getLogger("ROOT");<br>&nbsp;&nbsp;&nbsp;&nbsp; lbRoot.setLevel(ch.qos.logback.classic.Level.INFO);<br><br>&nbsp;&nbsp;&nbsp;&nbsp; // create the loggers<br>&nbsp;&nbsp;&nbsp;&nbsp; org.apache.log4j.Logger.getLogger("perfTest");<br>&nbsp;&nbsp;&nbsp;&nbsp; org.apache.log4j.Logger.getLogger("perfTest.ch");<br>&nbsp;&nbsp;&nbsp;&nbsp; org.apache.log4j.Logger.getLogger("perfTest.ch.qos");<br>&nbsp;&nbsp;&nbsp;&nbsp; org.apache.log4j.Logger.getLogger("perfTest.ch.qos.logback");<br>&nbsp;&nbsp;&nbsp;&nbsp;
 LoggerFactory.getLogger("perfTest");<br>&nbsp;&nbsp;&nbsp;&nbsp; LoggerFactory.getLogger("perfTest.ch");<br>&nbsp;&nbsp;&nbsp;&nbsp; LoggerFactory.getLogger("perfTest.ch.qos");<br>&nbsp;&nbsp;&nbsp;&nbsp; LoggerFactory.getLogger("perfTest.ch.qos.logback");<br>&nbsp;&nbsp; }<br>}<br><br>-- <br>Sébastien Pennec<br>sebastien@qos.ch<br><br>Logback: The reliable, generic, fast and flexible logging framework for Java.<br><a target="_blank" href="http://logback.qos.ch/">http://logback.qos.ch/</a><br>_______________________________________________<br>Logback-user mailing list<br>Logback-user@qos.ch<br><a target="_blank" href="http://qos.ch/mailman/listinfo/logback-user">http://qos.ch/mailman/listinfo/logback-user</a><br></div></div><br></div></div><br>

<hr size=1><a href="
http://us.rd.yahoo.com/evt=49981/*http://advision.webevents.yahoo.com/mailbeta/features_spam.html">Sucker-punch spam</a> with award-winning protection.<br> Try the <a href="
http://us.rd.yahoo.com/evt=49981/*http://advision.webevents.yahoo.com/mailbeta/features_spam.html">free Yahoo! Mail Beta.</a></body></html>