在IDEA中配置log4j,步骤很简单
1.在Maven中加入以下配置
commons-logging commons-logging1.2 log4j log4j1.2.16 org.slf4j slf4j-api1.5.6 jar org.slf4j slf4j-simple1.5.6
2.编写mybatis-config.xml文件
3.编写log4j.properties文件
log4j.rootLogger=error, Console log4j.logger.com.wocus.wine.dao=debug #Console log4j.appender.Console=org.apache.log4j.ConsoleAppender log4j.appender.Console.layout=org.apache.log4j.PatternLayout log4j.appender.Console.layout.ConversionPattern=%d [%t] %-5p [%c] - %m%n
4.在扫描mapper的xml文件中
注意:IDEA中的日志输出在output中,如果需要筛选,快捷键Ctrl+F
【拓展】
“细粒度”控制:Log4j打印出MyBatis中仅仅单个Mapper的配置。
DEBUG
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持考高分网。



