08.MyBatis整合Log4j

MyBatis整合Log4j:apache

1.导入log4j.jarapp

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

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

若是不指定,MyBatis就会根据一下顺序寻找日志:debug

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

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

日志级别:code

    DEBUG<INFO<WARN<ERRORxml

若是设置为info,则只显示info及以上级别的信息blog

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

相关文章
相关标签/搜索