摘要:java log=slf4j & logback
http://bbs.csdn.net/topics/380180401
程式呼叫logback啟動
LoggerContext lc = (LoggerContext)LoggerFactory.getILoggerFactory(); JoranConfigurator configurator = new JoranConfigurator(); configurator.setContext(lc); lc.reset(); try { configurator.doConfigure("src/com/bag/resources/logback-log.xml"); } catch (JoranException e) { e.printStackTrace(); } StatusPrinter.printInCaseOfErrorsOrWarnings(lc); System.out.println("==================="); logger.debug("Hello {}","debug message");
http://kyfxbl.iteye.com/blog/1188099
logback框架的初始化是由ContextInitializer完成的
try {
new ContextInitializer(defaultLoggerContext).autoConfig();
} catch (JoranException je) {
Util.report("Failed to auto configure default logger context", je);
}
http://wenku.baidu.com/view/d372fd85a0116c175f0e48b5.html?re=view
<appender name="DB" class="ch.qos.logback.classic.db.DBAppender">
<connectionSource class="ch.qos.logback.core.db.DriverManagerConnectionSource">
<dataSource class="com.mchange.v2.c3p0.ComboPooledDataSource">
<driverClass>com.mysql.jdbc.Driver</driverClass>
<url>jdbc:mysql://127.0.0.1:3306/databaseName</url>
<user>root</user>
<password>root</password>
</dataSource>
</connectionSource>
</appender>
http://www.yulezhandian.com/?p=324