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

log4jdbc使用

spring xml配置(拦截需要处理的dataSource连接)

<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.properties配置(日志级别为OFF时日志将不会生效)

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

?

maven依赖

<dependency>
               <groupId>net.sf.log4jdbc</groupId>
               <artifactId>log4jdbc3</artifactId>
               <version>1.2.1</version>
 </dependency>

??