日期:2014-05-16  浏览次数:20456 次

jdbc日志框架

spring中的配置

	<!-- log4jdbc可以将数据源执行的sql将占位符?替换成字符,并以日志打印出来. log4j配置: log4j.logger.jdbc.sqltiming=INFO    详情请看: http://code.google.com/p/rapid-framework/wiki/log4jdbc
	如oracle示例: 
		原来的sql: select * from user where birth_date = ? and username = ? and age > ?
		转换后sql: select * from user where birth_date = to_date('2010-08-13','yyyy-mm-dd') and username = 'badqiu' and age > 20
	 -->
	<bean id="log4jdbcInterceptor" class="net.sf.log4jdbc.DataSourceSpyInterceptor" />
    <bean id="dataSourceLog4jdbcAutoProxyCreator" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
       <property name="interceptorNames">
           <list>
              <value>log4jdbcInterceptor</value>        
           </list>
       </property>
       <property name="beanNames">
           <list>
              <value>dataSource</value>
           </list>
       </property>
    </bean>

?log4j配置:

log4j.logger.jdbc.sqlonly=OFF  
log4j.logger.jdbc.sqltiming=INFO  
log4j.logger.jdbc.audit=OFF  
log4j.logger.jdbc.resultset=OFF  
log4j.logger.jdbc.connection=OFF 

?所需jar包:见附件

其中

DataSourceSpyInterceptor为rapid-framework框架中自己扩展的,原包是里没有。

?