zoukankan      html  css  js  c++  java
  • ibatis和myBatis打印sql语句的log4j配置文件

    1/ibatis: 

    log4j.rootLogger=debug, stdout, logfile
     
    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
    log4j.logger.java.sql.ResultSet=DEBUG
     
     
    log4j.logger.org.springframework=ERROR
    log4j.logger.org.compass=ERROR
     
     
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
    log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n
     
    log4j.appender.logfile=org.apache.log4j.RollingFileAppender
    log4j.appender.logfile.File=empi.log
    log4j.appender.logfile.MaxFileSize=512KB
    log4j.appender.logfile.MaxBackupIndex=3
    log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
    log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n


    ****************************************
    2/myBatis 
     
     

    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
     
    <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
      <appender name="console" class="org.apache.log4j.ConsoleAppender"> 
        <param name="Target" value="System.out"/> 
        <layout class="org.apache.log4j.PatternLayout"> 
          <param name="ConversionPattern" value="%d{MMM dd yyyy HH:mm:ss,SSS} %-5p %c - %m%n"/> 
        </layout> 
      </appender> 
      
      <appender class="org.apache.log4j.RollingFileAppender"  
            name="file">  
            <param name="File" value="ts.log" />  
            <param name="MaxFileSize" value="100KB" />  
            <param name="MaxBackupIndex" value="2" />  
            <layout class="org.apache.log4j.PatternLayout">  
                <param name="ConversionPattern"  
                    value="=%d %-5p [%t] %-17c{2} (%13F:%L) %3x - %m%n" />  
            </layout>  
        </appender>  
     
      <category name="net.carefx" additivity="false">
    <priority value="DEBUG"/>
    <appender-ref ref="console"/>
    </category>
        <category name="org.springframework" additivity="false">
            <priority value="ERROR"/>
            <appender-ref ref="console"/>
        </category>    
        <category name="org.springframework.orm.ibatis3" additivity="false">
            <priority value="ERROR"/>
            <appender-ref ref="console"/>
        </category> 
         <category name="org.apache.ibatis" additivity="false">
            <priority value="DEBUG"/>
            <appender-ref ref="console"/>
        </category>   
         <category name="java.sql" additivity="false">
            <priority value="ERROR"/>
            <appender-ref ref="console"/>
        </category>
     
     
     
     
        <logger name="org.apache.ibatis.common.jdbc.SimpleDataSource">  
            <level value="debug" />  
        </logger>  
     
        <logger name="org.apache.ibatis.common.jdbc.SimpleDataSource">  
            <level value="debug" />  
        </logger>  
     
        <logger name="org.apache.ibatis.common.jdbc.ScriptRunner">  
            <level value="debug" />  
        </logger>  
     
        <logger name="org.apache.ibatis.common.jdbc.SqlMapClientDelegate">  
            <level value="debug" />  
        </logger>  
     
        <logger name="java.sql.Connection">  
            <level value="debug" />  
        </logger>  
     
        <logger name="java.sql.Statement">  
            <level value="debug" />  
        </logger>  
     
        <logger name="java.sql.PreparedStatement">  
            <level value="debug" />  
        </logger>  
     
        <logger name="java.sql.ResultSet">  
            <level value="debug" />  
        </logger>     
      <root> 
        <priority value ="ERROR" /> 
        <appender-ref ref="console" /> 
      </root>
     
       
    </log4j:configuration>

  • 相关阅读:
    Spring攻略学习笔记(3.00)AOP核心概念和术语
    zoj 3494
    第43周星期五
    findBugs学习小结
    第42周星期日
    Cookie知识小结
    第42周星期三
    第42周星期六
    第43周星期四小结
    第43周星期二
  • 原文地址:https://www.cnblogs.com/huapox/p/3516387.html
Copyright © 2011-2022 走看看