1. 程式人生 > >druid log4j配置

druid log4j配置

log4j druid

1. druid配置中必須加上以下filter

<property name="filters" value="log4j" />


druid已封裝好的filter

druid.filters.default=com.alibaba.druid.filter.stat.StatFilter

druid.filters.stat=com.alibaba.druid.filter.stat.StatFilter

druid.filters.mergeStat=com.alibaba.druid.filter.stat.MergeStatFilter

druid.filters.counter=com.alibaba.druid.filter.stat.StatFilter

druid.filters.encoding=com.alibaba.druid.filter.encoding.EncodingConvertFilter

druid.filters.log4j=com.alibaba.druid.filter.logging.Log4jFilter

druid.filters.slf4j=com.alibaba.druid.filter.logging.Slf4jLogFilter

druid.filters.commonlogging=com.alibaba.druid.filter.logging.CommonsLogFilter

druid.filters.commonLogging=com.alibaba.druid.filter.logging.CommonsLogFilter

druid.filters.wall=com.alibaba.druid.wall.WallFilter

druid.filters.config=com.alibaba.druid.filter.config.ConfigFilter


2.log4j.xml

 	<logger name="druid.sql" additivity="false">
        <level value="debug" />
		<appender-ref ref="console"/>
    </logger>
 	<logger name="druid.sql.DataSource" additivity="false">
        <level value="error" />
		<appender-ref ref="console"/>
    </logger>
 	<logger name="druid.sql.Connection" additivity="false">
        <level value="error" />
		<appender-ref ref="console"/>
    </logger>
 	<logger name="druid.sql.Statement" additivity="false">
        <level value="debug" />
		<appender-ref ref="console"/>
    </logger>
 	<logger name="druid.sql.ResultSet" additivity="false">
        <level value="debug" />
		<appender-ref ref="console"/>
    </logger>



druid log4j配置