代碼:xml
import ch.qos.logback.classic.joran.JoranConfigurator;get
File logbackFile = new File("./conf/logback.xml");it
if (logbackFile.exists()) {io
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();class
JoranConfigurator configurator = new JoranConfigurator();import
configurator.setContext(lc);im
lc.reset();co
try {logback
configurator.doConfigure(logbackFile);config
} catch (JoranException e) {
e.printStackTrace(System.err); System.exit(-1);
}
}