// LoggerFactory.getLogger()方法的参数使用的是当前类的class
private static final Logger logger = LoggerFactory.getLogger(LogDemo.class);
public static void main(String[] args) {
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");
}
}
logback系列之六:在Test类中加载logback配置文件
最新推荐文章于 2023-03-22 11:19:25 发布