方法一:
这种方法是mybatis官网上介绍的,比较好用:
log4j.properties:
log4j.rootLogger=ERROR,console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=[%-5p] %d [%c]%n%m%n
log4j.logger.com.westward.mapper.UsersOperation=TRACE
其中:
com.westward.mapper.UsersOperation是mapper xml文件的命名空间,也可以配成包com.westward.mapper,也可以更细粒度的控制具体方法:com.westward.mapper.UsersOperation.selectAllUsers
方法二:
log4j.properties:
log4j.rootLogger=DEBUG,console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=[%-5p] %d [%c]%n%m%n
log4j.logger.org.apache=INFO
推荐方法一,更容易配置,容易理解。