druid 数据源 sql控制台输出

开发环境使用

spring

    <bean id="log-filter" class="com.alibaba.druid.filter.logging.Slf4jLogFilter">
        <property name="connectionLogEnabled" value="false"/>
        <property name="statementLogEnabled" value="false"/>
        <property name="resultSetLogEnabled" value="true"/>
        <property name="statementExecutableSqlLogEnable" value="true"/>
    </bean>
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close" abstract="true">
        <property name="proxyFilters">
            <list>
                <ref bean="log-filter"/>
            </list>
        </property>
    </bean>  

log4j.xml

  <logger name="druid.sql.Statement" additivity="false">
        <level value="DEBUG"/>
        <appender-ref ref="consoleAppender"/>
    </logger>
<logger name="druid.sql.ResultSet"  additivity="false">
<level value="DEBUG"/>
<appender-ref ref="consoleAppender"/>
</logger>
 

 

posted @ 2018-04-12 15:52  zfzf1  阅读(1083)  评论(0编辑  收藏  举报