开发环境使用
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>