hibernate和mybatis混用时mybatis打印sql日志
直接在mybatis-config.xml配置文件中新增一个配置
<settings>
<setting name="lazyLoadingEnabled" value="false"/>
<setting name="logImpl" value="STDOUT_LOGGING"/>
</settings>
注意,这个时候,也要有对应的log4j.properties配置文件
log4j.rootCategory=INFO,consoleLog,toFile,toERROR,toDEBUG
log4j.category.jp.terasoluna=DEBUG
log4j.category.org.springframework=INFO
log4j.logger.net.sf.json.JSONObject=FATAL
log4j.appender.consoleLog=org.apache.log4j.ConsoleAppender
log4j.appender.consoleLog.Target = System.out
log4j.appender.consoleLog.layout.ConversionPattern=%x %d{yyyy-MM-dd HH:mm:ss} %C.%F %T line:%L- %m%n
log4j.appender.toDEBUG=org.apache.log4j.DailyRollingFileAppender
log4j.appender.toDEBUG.file=../log/debug.log
log4j.appender.toDEBUG.Threshold=DEBUG
log4j.appender.toDEBUG.layout=com.fyz.api.common.logger.ExPatternLayout
log4j.appender.toDEBUG.layout.ConversionPattern=%x %d{yyyy-MM-dd HH:mm:ss} %C.%F %T line:%L- %m%n
log4j.logger.com.ibatis=DEBUG
log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=DEBUG
log4j.logger.com.ibatis.common.jdbc.ScriptRunner=DEBUG
log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=DEBUG
log4j.logger.java.sql.Connection=DEBUG
log4j.logger.java.sql.Statement=DEBUG
log4j.logger.java.sql.PreparedStatement=DEBUG
上一篇: Java IO 再理解