引入依赖
<dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.12</version> </dependency>
resources目录下添加log4j.xml配置文件
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/' > <appender name="STDOUT" class="com.apache.log4j.ConsoleAppender"> <param name="Encoding" value="UTF-8" /> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%-5p %d{MM-dd HH:mm:ss,SSS} %m (%f:%l) \n"/> </layout> </appender> <logger name="java.sql"> <level value="debug" /> </logger> <logger name="org.apache.ibatis"> <level value="info" /> </logger> <root> <level value="debug" /> <appender-ref ref="STDOUT" /> </root> </log4j:configuration>
mybatis-config.xml中添加配置(注意该配置中添加标签有顺序要求)
<settings> <!--标准的日志--> <setting name="logImpl" value="STDOUT_LOGGING"/> </settings>
标签:xml,12,配置文件,添加,整合,log4j From: https://www.cnblogs.com/ixtao/p/17156480.html