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或以上開發

相關文章
相關標籤/搜索