MyBatis在log4j的输出配置,xml方式

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true">
    <!-- 输出日志到控制台-->
    <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
        <!-- 信息输出格式 -->
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="[%d{dd/MM/yy hh:mm:ss:sss z}] %5p %c{2}: %m%n" />
        </layout>
    </appender>
    <!-- 输出日志到文件-->
    <appender name="FILE" class="org.apache.log4j.RollingFileAppender">
         <!-- 文件路径 -->
        <param name="file" value="${user.home}/yanglong-frameworkutil.log" />
        <param name="append" value="true" />
        <!-- 文件大小 -->
        <param name="maxFileSize" value="1MB" />
        <!-- 文件备份数量 -->
        <param name="maxBackupIndex" value="1000" />
        <!-- 信息输出格式 -->
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d [%t] %-5p %C{6} (%F:%L) - %m%n" />
        </layout>
    </appender>
    <!-- 下面是打印mybatis语句的配置-->
    <logger name="com.ibatis" additivity="true">
        <level value="DEBUG" />
        <appender-ref ref="CONSOLE" />
    </logger>
    <logger name="java.sql.Connection" additivity="true">
        <level value="DEBUG" />
        <appender-ref ref="CONSOLE" />
    </logger>
    <logger name="java.sql.Statement" additivity="true">
        <level value="DEBUG" />
        <appender-ref ref="CONSOLE" />
    </logger>
    <logger name="java.sql.PreparedStatement" additivity="true">
        <level value="DEBUG" />
        <appender-ref ref="CONSOLE" />
    </logger>
    <logger name="java.sql.ResultSet" additivity="true">
        <level value="DEBUG" />
        <appender-ref ref="CONSOLE" />
    </logger>
    <root>
        <level value="DEBUG" />
        <appender-ref ref="CONSOLE" />
        <appender-ref ref="FILE" />
    </root>
</log4j:configuration>

你可能感兴趣的:(log4j,mybatis,Mbatis log4j)