08.MyBatis整合Log4j

MyBatis整合Log4j:

1.导入log4j.jar

2.在conf.xml中开启日志文件:

1 <!-- 配置日志文件 -->
2     <settings>
3         <setting name="logImpl" value="LOG4J"/>
4     </settings>

如果不指定,MyBatis就会根据一下顺序寻找日志:

SLF4J -> Apache Commons Logging -> Log4j 2 -> Log4j -> jdk Logging

3.编写配置日志输出文件:log4j.properties

1 # Global logging configuration\uff0c\u5efa\u8bae\u5f00\u53d1\u73af\u5883\u4e2d\u8981\u7528debug
2 log4j.rootLogger=DEBUG, stdout
3 # Console output...
4 log4j.appender.stdout=org.apache.log4j.ConsoleAppender
5 log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
6 log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n

日志级别:

    DEBUG<INFO<WARN<ERROR

如果设置为info,则只显示info及以上级别的信息

建议:在开发时设置debug,在运行时设置为info或以上

 

posted @ 2019-08-13 16:56  Food丶馒头  阅读(409)  评论(0编辑  收藏  举报