开发者社区> 问答> 正文

durid 配置日志 输出如下 - 数据源报错

"

log4j.properties

#log4j.rootLogger = [ level ] , appenderName, appenderName, ...
log4j.rootLogger = INFO, console, R
#level=INFO,all can be output
#console is set to be a ConsoleAppender
log4j.appender.console = org.apache.log4j.ConsoleAppender
#console have four patterns
#org.apache.log4j.HTMLLayout
#org.apache.log4j.PatternLayout
#org.apache.log4j.SimpleLayout
#org.apache.log4j.TTCCLayout
log4j.appender.console.layout = org.apache.log4j.PatternLayout
#define the output type
log4j.appender.console.layout.ConversionPattern = %-d{yyyy-MM-dd HH����ss} [%c]-[%p] %m%n
#file is set to output to a extra file
log4j.appender.R = org.apache.log4j.RollingFileAppender
#the absolute route of the log4j file
log4j.appender.R.File = ${webapp.root}/WEB-INF/logs/gzsfpy.log
#the size
log4j.appender.R.MaxFileSize = 500KB
#back up a file
log4j.appender.R.MaxBackupIndex = 1
log4j.appender.R.layout = org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%-d{yyyy-MM-dd HH\:mm\:ss} [%c]-[%p] - %m%n

#druid\u65E5\u5FD7
log4j.logger.druid.sql=debug,stdout,infolog
spring关节镜配置

<bean name="dataSource" class="com.alibaba.druid.pool.DruidDataSource"
		init-method="init" destroy-method="close">
		<property name="url" value="${jdbc_url}"></property>
		<property name="username" value="${jdbc_username}"></property>
		<property name="password" value="${jdbc_password}"></property>

		<property name="maxActive" value="20" />
		<property name="initialSize" value="1" />
		<property name="maxWait" value="60000" />
		<property name="minIdle" value="1" />
		<property name="timeBetweenEvictionRunsMillis" value="60000" />
		<property name="minEvictableIdleTimeMillis" value="300000" />
		<property name="testWhileIdle" value="true" />
		<property name="testOnBorrow" value="false" />
		<property name="testOnReturn" value="false" />
		<property name="poolPreparedStatements" value="true" />
		<property name="maxPoolPreparedStatementPerConnectionSize" value="50" />

		<property name="filters" value="stat" /> 
		<property name="timeBetweenLogStatsMillis" value="300000" />
        <!-- 监控数据库 -->
        <property name="proxyFilters">
            <list>
                <ref bean="stat-filter" />
                <ref bean="wall-filter" />
                <ref bean="log-filter" />
            </list> 
        </property>
 	</bean>
 
 
	<bean id="stat-filter" class="com.alibaba.druid.filter.stat.StatFilter">
        <property name="slowSqlMillis" value="3000" />
        <property name="logSlowSql" value="true" />
        <property name="mergeSql" value="true" />
    </bean>
     
    <bean id="log-filter" class="com.alibaba.druid.filter.logging.Log4jFilter">
        <property name="resultSetLogEnabled" value="false" />
        <property name="statementExecutableSqlLogEnable" value="true" />
    </bean>
     
    <bean id="wall-filter" class="com.alibaba.druid.wall.WallFilter">
        <property name="dbType" value="mysql" />
    </bean>



是引用druid-1.0.18.jar

java.lang.NullPointerException

    at com.alibaba.druid.pool.DruidDataSource.getStatValueAndReset(DruidDataSource.java:1572)
    at com.alibaba.druid.pool.DruidDataSource.logStats(DruidDataSource.java:1511)
    at com.alibaba.druid.pool.DruidDataSource$LogStatsThread.run(DruidDataSource.java:1757)"

展开
收起
montos 2020-05-31 16:11:27 490 0
1 条回答
写回答
取消 提交回答
  • 空指针,日志给全######<bean id="dataSource"class="com.alibaba.druid.pool.DruidDataSource" init-method="init"destroy-method="close"> 那个name该改成id吧######这就是报错的全部信息

    2020-05-31 16:11:40
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
PostgresChina2018_赖思超_PostgreSQL10_hash索引的WAL日志修改版final 立即下载
Kubernetes下日志实时采集、存储与计算实践 立即下载
日志数据采集与分析对接 立即下载