[转]MyBatis - MyBatis使用log4j2显示sql和结果集

mybatis-config.xml

<settings>
        <!--打印SQL语句 STDOUT_LOGGING-->
        <setting name="logImpl" value="LOG4J2" />
</settings>

log4j2.xml

<?xml version="1.0" encoding="UTF-8"?>
<configuration status="OFF">
  <appenders>
    <Console name="Console" target="SYSTEM_OUT">
      <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
    </Console>
  </appenders>
  <loggers>
    <logger name="log4j.logger.noModule" level="fatal" additivity="false">
      <appender-ref ref="Console"/>
    </logger>
    <logger name="log4j.logger.org.mybatis.jpetstore" level="trace" additivity="false">
      <appender-ref ref="Console"/>
    </logger>
    <logger name="log4j.logger.com.opensymphony.xwork2" level="debug" additivity="false">
      <appender-ref ref="Console"/>
    </logger>
    <logger name="log4j.logger.com.ibatis" level="trace" additivity="false">
      <appender-ref ref="Console"/>
    </logger>
    <logger name="log4j.logger.com.ibatis.common.jdbc.SimpleDataSource" level="debug" additivity="false">
      <appender-ref ref="Console"/>
    </logger>
    <logger name="log4j.logger.com.ibatis.common.jdbc.ScriptRunner" level="debug" additivity="false">
      <appender-ref ref="Console"/>
    </logger>
    <logger name="log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate" level="debug" additivity="false">
      <appender-ref ref="Console"/>
    </logger>
    <logger name="log4j.logger.org.mybatis" level="debug" additivity="false">
      <appender-ref ref="Console"/>
    </logger>
    <logger name="log4j.logger.java.sql" level="debug" additivity="false">
      <appender-ref ref="Console"/>
    </logger>
    <logger name="log4j.logger.java.sql.Connection" level="debug" additivity="false">
      <appender-ref ref="Console"/>
    </logger>
    <logger name="log4j.logger.java.sql.Statement" level="debug" additivity="false">
      <appender-ref ref="Console"/>
    </logger>
    <logger name="log4j.logger.java.sql.PreparedStatement" level="debug" additivity="false">
      <appender-ref ref="Console"/>
    </logger>
    <logger name="log4j.logger.java.sql.ResultSet" level="debug" additivity="false">
      <appender-ref ref="Console"/>
    </logger>
    <root level="trace">
      <appender-ref ref="Console"/>
    </root>
  </loggers>
</configuration>

 

 

[转]MyBatis - MyBatis使用log4j2显示sql和结果集

上一篇:ElasticSearch 索引 VS MySQL 索引


下一篇:mysql知识点