mybatis怎么配置log4j打印出sql语句
1个回答
展开全部
mybaits提供两种日志打印的机制,一个是common;一个是slf4j
Java代码
@Test
public void shouldUseCommonsLogging() {
LogFactory.useCommonsLogging();
Log log = LogFactory.getLog(Object.class);
logSomething(log);
assertEquals(log.getClass().getName(), JakartaCommonsLoggingImpl.class.getName());
}
@Test
public void shouldUseLog4J() {
LogFactory.useLog4JLogging();
Log log = LogFactory.getLog(Object.class);
logSomething(log);
assertEquals(log.getClass().getName(), Log4jImpl.class.getName());
}
Java代码
@Test
public void shouldUseCommonsLogging() {
LogFactory.useCommonsLogging();
Log log = LogFactory.getLog(Object.class);
logSomething(log);
assertEquals(log.getClass().getName(), JakartaCommonsLoggingImpl.class.getName());
}
@Test
public void shouldUseLog4J() {
LogFactory.useLog4JLogging();
Log log = LogFactory.getLog(Object.class);
logSomething(log);
assertEquals(log.getClass().getName(), Log4jImpl.class.getName());
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询