mybatis的log打印SQL的问题
web.xml的配置也正确,log4j.properties配置也添加了。
## Log4J Settings for log4j 1.2.x (via jakarta-commons-logging)## The five logging levels used by Log are (in order):# # 1. DEBUG (the least serious)# 2. INFO# 3. WARN# 4. ERROR# 5. FATAL (the most serious)# Set root logger level to INFO and append to stdoutlog4j.rootLogger=INFO,stdout,filelog4j.appender.stdout=org.apache.log4j.ConsoleAppenderlog4j.appender.stdout.layout=org.apache.log4j.PatternLayout# Pattern to output the caller's file name and line number.log4j.appender.stdout.layout.ConversionPattern=[%p]%-d{yyyy-MM-dd HH\:mm\:ss}[%c\:%L] %m%n log4j.appender.file=org.apache.log4j.DailyRollingFileAppenderlog4j.appender.file.File=D://mvc.loglog4j.appender.file.DatePattern='.'yyyy-MM-ddlog4j.appender.file.layout=org.apache.log4j.PatternLayoutlog4j.appender.file.layout.ConversionPattern=[%p]%-d{yyyy-MM-dd HH\:mm\:ss}[%c\:%L] %m%n # Print only messages of level ERROR or above in the package noModule.log4j.logger.noModule=DEBUG# Spring Stufflog4j.logger.org.springframework=FATAL#kuaibalog4j.logger.com.student=DEBUG# Sqllog4j.logger.java.sql.Connection=DEBUGlog4j.logger.java.sql.Statement=DEBUGlog4j.logger.java.sql.PreparedStatement=DEBUGlog4j.logger.java.sql.ResultSet=DEBUG
?但是仍然不能打印sql语句,折腾了好久,看到控制台输出关于sfl4j的消息,网上查询了好久,才发现是缺少jar包。加入以上两个jar包就解决了。
<dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.16</version></dependency><dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.6.1</version></dependency><dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.6.1</version></dependency>
?