首页 > 代码库 > druid log4j配置
druid log4j配置
1. druid配置中必须加上以下filter
<property name="filters" value="http://www.mamicode.com/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="http://www.mamicode.com/debug" /> <appender-ref ref="console"/> </logger> <logger name="druid.sql.DataSource" additivity="false"> <level value="http://www.mamicode.com/error" /> <appender-ref ref="console"/> </logger> <logger name="druid.sql.Connection" additivity="false"> <level value="http://www.mamicode.com/error" /> <appender-ref ref="console"/> </logger> <logger name="druid.sql.Statement" additivity="false"> <level value="http://www.mamicode.com/debug" /> <appender-ref ref="console"/> </logger> <logger name="druid.sql.ResultSet" additivity="false"> <level value="http://www.mamicode.com/debug" /> <appender-ref ref="console"/> </logger>
druid log4j配置