<div>Hi,</div><div><br></div><div>I am new in Logback framework. I want to use mysql database to store my log. So I have set my logback-test.xml file in the following way:</div><div><br></div><div><div><?xml version="1.0" encoding="UTF-8"?></div>
<div><configuration></div><div>Â Â <appender name="DB" class="ch.qos.logback.classic.db.DBAppender"></div><div>Â Â Â <connectionSource class="ch.qos.logback.core.db.DriverManagerConnectionSource"> Â Â Â </div>
<div>Â Â Â Â Â <driverClass>com.mysql.jdbc.Driver</driverClass></div><div>Â Â Â Â Â <url>jdbc:mysql://localhost:3306/testlogback</url></div><div>Â Â Â Â Â <user>root</user></div><div>Â Â Â Â Â <password>test</password> Â Â Â </div>
<div>Â Â Â </connectionSource></div><div>Â Â </appender>Â </div><div><br></div><div>Â Â <root level="debug"></div><div>Â Â Â <appender-ref ref="DB" /></div><div>Â Â </root></div><div>
</configuration></div></div><div><br></div><div>After that I created a database which is called "testlogback". </div><div><br></div><div>I have two simple java classes. The code snippet is:</div><div><div>
<span class="Apple-tab-span" style="white-space:pre"> </span></div><div>Â <span class="Apple-style-span" style="white-space: pre;">public class TestLogger {
public static void main(String[] args){</span></div><div><span class="Apple-style-span" style="white-space: pre;"><br></span></div><div><span class="Apple-style-span" style="white-space: pre;"> Logger logger = LoggerFactory.getLogger("com.lashpoint.TestLogger");
LoggerContext lc=(LoggerContext) LoggerFactory.getILoggerFactory();
StatusPrinter.print(lc);</span></div><div><span class="Apple-style-span" style="white-space: pre; "><br></span></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>logger.debug("Test start");<span class="Apple-tab-span" style="white-space:pre"> </span></div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>System.out.println("Hello World Logback");<span class="Apple-tab-span" style="white-space:pre"> </span></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>SalaryTestLogger test=new SalaryTestLogger ();</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>test.setHour(0);</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>test.setSalary(100);<span class="Apple-tab-span" style="white-space:pre"> </span></div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>System.out.println("Division: "+test.getSalary());<span class="Apple-tab-span" style="white-space:pre"> </span></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>logger.debug("Test end");</div>
</div><div>    }</div><div>}</div><div><br></div><div>public class SalaryTestLogger { </div><div><br></div><div>............................</div><div><div>     public SalaryTestLogger(){</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>logger=LoggerFactory.getLogger("com.lashpoint.SalaryTestLogger ");</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div></div><div>................</div>..........................<div><br></div><div>}<br><div><br></div><div>After running the code, I got the following output (However, I put StatusPrinter.print(lc) to see internal state).</div>
<div><br></div><div><div>Driver name=MySQL-AB JDBC Driver</div><div>Driver version=mysql-connector-java-5.0.7 ( $Date: 2007-03-09 22:13:57 +0100 (Fri, 09 Mar 2007) $, $Revision: 6341 $ )</div><div>supportsGetGeneratedKeys=true</div>
<div>true</div><div>12:08:37,312 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback-test.xml] at [file:/E:/DevTools/projects/Test/LogbackTest/src/com/lashpoint/logger/logback-test.xml]</div>
<div>12:08:37,421 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set</div><div>12:08:37,421 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.classic.db.DBAppender]</div>
<div>12:08:37,437 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [DB]</div><div>12:08:37,468 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Pushing component [connectionSource] on top of the object stack.</div>
<div>12:08:37,812 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Popping appender named [DB] from the object stack</div><div>12:08:37,812 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to DEBUG</div>
<div>12:08:37,812 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [DB] to Logger[ROOT]</div><div><br></div><div>Hello World Logback</div><div>Salry Per Hour: 0.0</div><div><br></div>
<div>The MOST INTERESTING THING is that, it did not log anything to logging_event, logging_event_exception, logging_event_property tables.</div><div><br></div><div>So I think I am missing something. I would be glad if someone kindly help me to solve this issue.</div>
<br>-- <br>Thanks<br> Â Mohammad Firoj Haider<br>Â Â <br><br><br>
</div></div>