<div dir="ltr"><div>Absolutely...</div>
<div>Here is the config file.</div>
<div> </div>
<div><configuration></div>
<div> <consolePlugin /></div>
<div><br> <appender name="DB" class="ch.qos.logback.classic.db.DBAppender"><br> <connectionSource class="ch.qos.logback.core.db.DriverManagerConnectionSource"><br> <driverClass>com.mysql.jdbc.Driver</driverClass><br>
<url>jdbc:mysql://localhost:3306/Greg</url><br> <user>greg</user><br> <password>greg</password><br> </connectionSource><br> </appender></div>
<div><br> <appender name="HSQLDB" class="ch.qos.logback.classic.db.DBAppender"><br> <connectionSource class="ch.qos.logback.core.db.DriverManagerConnectionSource"><br> <driverClass>org.hsqldb.jdbcDriver</driverClass><br>
<url>jdbc:hsqldb:hsql://localhost/</url><br> <user>sa</user><br> <password></password><br> </connectionSource><br> </appender></div>
<div><br> <appender name="STDOUT"<br> class="ch.qos.logback.core.ConsoleAppender"><br> <layout class="ch.qos.logback.classic.PatternLayout"><br> <Pattern>%date{HH:mm:ss.SSS} [%thread] %-5level %logger{36} [%file : %line] - %msg%n</Pattern><br>
</layout><br> </appender></div>
<div><br><appender name="FILE" class="ch.qos.logback.core.FileAppender"><br> <layout class="ch.qos.logback.classic.html.HTMLLayout"><br> <pattern>%date %relative%thread%mdc%level%logger%msg</pattern><br>
</layout><br> <File>C:/tools/test.html</File><br></appender></div>
<div> <!--<br><appender name="FLAT" class="ch.qos.logback.core.FileAppender"><br> <File>H:/tools/testFile.log</File><br> <layout class="ch.qos.logback.classic.PatternLayout"><br>
<Pattern>%date %relative%thread%mdc%level%logger%msg%n</Pattern><br> </layout><br> </appender></div>
<div> --><br><!--<br> <appender name="FILE" class="ch.qos.logback.core.FileAppender"><br> <File>testFile.log</File><br> <Append>true</Append></div>
<div> <layout class="ch.qos.logback.classic.PatternLayout"><br> <Pattern>%date [%thread] %-5level %logger{35} - %msg%n</Pattern><br> </layout><br> </appender><br> --></div>
<div> <root><br> <level value="debug" /><br> <appender-ref ref="DB" /><br> </root><br></configuration></div>
<div> </div>
<div>Right now as you can see is set to write to a DB which is a MySQl database.</div>
<div>Here is the Java code I'm using to test this.</div>
<div> </div>
<div> </div>
<div>public class DBConnector {<br> Logger logger = null;</div>
<div> public static void main(String[] args) {<br> DBConnector dbc = new DBConnector();<br> dbc.doSomething();<br> }</div>
<div> public void doSomething(){<br> logger = LoggerFactory.getLogger(DBConnector.class);<br> readConfig();<br> PerformanceBenchmark();<br> }</div>
<div> public void PerformanceBenchmark()<br> {</div>
<div> // Get current time<br> long start = System.currentTimeMillis();</div>
<div> for (int i = 0; i < 10000; ++i)<br> {<br> logger.debug("INFO Entering application.");<br> <a href="http://logger.info">logger.info</a>("INFO Entering application.");<br> }</div>
<div> Foo f = new Foo();<br> f.doIt();<br> <a href="http://logger.info">logger.info</a>("Exiting Application");</div>
<div> // Get elapsed time in milliseconds<br> try {<br> throw new Exception("Testing exception");<br> }<br> catch(Exception e)<br> {<br> long elapsedTimeMillis = System.currentTimeMillis()-start;<br>
<a href="http://logger.info">logger.info</a>("Time in ms is: " + elapsedTimeMillis, e);<br> }<br> //System.out.println(elapsedTimeMillis);<br> }</div>
<div> private void readConfig()<br> {<br> LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();<br> try {<br> JoranConfigurator configurator = new JoranConfigurator();<br> lc.shutdownAndReset();<br>
configurator.setContext(lc);<br> configurator.doConfigure("src/DBConnectorXML.xml");<br> } catch (JoranException je) {<br> StatusPrinter.print(lc);<br> }<br> }<br>}</div>
<div> </div>
<div> </div>
<div>public class Foo {<br> static final Logger logger = LoggerFactory.getLogger(Foo.class);</div>
<div> public void doIt() {<br> logger.debug("Got in here!");<br> }<br>}<br><br>As you can see I'm just playing aroung with it.....</div>
<div>The code is complete... meaning you can compile it and run it.</div>
<div>See if you can reproduce the problem..... </div>
<div>Thanks</div>
<div> </div>
<div> </div>
<div> </div>
<div><br> </div>
<div class="gmail_quote">On Mon, Sep 22, 2008 at 2:11 PM, Ceki Gulcu <span dir="ltr"><listid@qos.ch></span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><br><br>Interesting. Could you please share your config file and code?<br>
<div>
<div></div>
<div class="Wj3C7c"><br>Greg Flex wrote:<br>> Hi all,<br>> I'm running some benchmarking and I've noticed that when calling logger.xxx<br>> in a loop (10,000 iterations) only about 3964 are written. I'm testing<br>
> this with both<br>> MySQL and HSQLDB databases.<br>> Can someone please let me know what's seems to be a problem?<br>> Do I need to configure this in some config file?<br>> How many times I can write at once to a database?<br>
> Thanks<br>><br>><br><br><br></div></div><font color="#888888">--<br>Ceki Gülcü<br>Logback: The reliable, generic, fast and flexible logging framework for Java.<br><a href="http://logback.qos.ch/" target="_blank">http://logback.qos.ch</a><br>
_______________________________________________<br>Logback-user mailing list<br>Logback-user@qos.ch<br><a href="http://qos.ch/mailman/listinfo/logback-user" target="_blank">http://qos.ch/mailman/listinfo/logback-user</a><br>
</font></blockquote></div><br></div>