1
回答
Druid Log4j配置文件log4j.xml
终于搞明白,存储TCO原来是这样算的>>>   
 使用druid的日志监控数据库sql的执行情况,并记录到日志中,在spring的数据源配置中已经配置log4j拦截器<property name="filters" value="stat" />。并且也配置了log4j的配置文件log4j.xml
<appender name="SERVICE_DRUID" class="org.apache.log4j.DailyRollingFileAppender">
        <param name="file" value="/opt/applog/log_test.log" />
        <param name="threshold" value="debug" />
        <param name="append" value="true" />
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="'%d', '%p', '%t', '%c', '%m'%n"/>            
        </layout>

    </appender>

但是日志输出后并没有sql语句。

'2016-07-01 09:35:40,412', 'DEBUG', 'http-8080-7', 'com.alibaba.druid.pool.PreparedStatementPool', '{conn-10001, pstmt-20015} enter cache'
'2016-07-01 09:35:40,412', 'DEBUG', 'http-8080-7', 'com.alibaba.druid.pool.PreparedStatementPool', '{conn-10001, pstmt-20015} enter cache'
'2016-07-01 09:35:40,430', 'DEBUG', 'http-8080-7', 'com.alibaba.druid.pool.PreparedStatementPool', '{conn-10001, pstmt-20016} enter cache'
'2016-07-01 09:35:40,430', 'DEBUG', 'http-8080-7', 'com.alibaba.druid.pool.PreparedStatementPool', '{conn-10001, pstmt-20016} enter cache'
'2016-07-01 09:35:40,443', 'DEBUG', 'http-8080-7', 'com.alibaba.druid.pool.PreparedStatementPool', '{conn-10001, pstmt-20017} enter cache'
'2016-07-01 09:35:40,443', 'DEBUG', 'http-8080-7', 'com.alibaba.druid.pool.PreparedStatementPool', '{conn-10001, pstmt-20017} enter cache'
'2016-07-01 09:35:40,455', 'DEBUG', 'http-8080-7', 'com.alibaba.druid.pool.PreparedStatementPool', '{conn-10001, pstmt-20018} enter cache'
'2016-07-01 09:35:40,455', 'DEBUG', 'http-8080-7', 'com.alibaba.druid.pool.PreparedStatementPool', '{conn-10001, pstmt-20018} enter cache'
'2016-07-01 09:35:40,471', 'DEBUG', 'http-8080-7', 'com.alibaba.druid.pool.PreparedStatementPool', '{conn-10001, pstmt-20019} enter cache'
'2016-07-01 09:35:40,471', 'DEBUG', 'http-8080-7', 'com.alibaba.druid.pool.PreparedStatementPool', '{conn-10001, pstmt-20019} enter cache'

在druid的日志配置中是使用的log4j.properties配置,而且介绍不是很清楚,求大神指点。

举报
飘摇云飞YF
发帖于1年前 1回/626阅
顶部