logback使用c3p0连接池没有写配置文件会报警告处理方法

在这里插入图片描述
com.mchange.v2.cfg.DelayedLogItem [ level -> FINE, text -> “The configuration file for resource identifier ‘/mchange-commons.properties’ could not be found. Skipping.”, exception -> null]
com.mchange.v2.cfg.DelayedLogItem [ level -> FINE, text -> “The configuration file for resource identifier ‘/mchange-log.properties’ could not be found. Skipping.”, exception -> null]
com.mchange.v2.cfg.DelayedLogItem [ level -> FINE, text -> “The configuration file for resource identifier ‘/c3p0.properties’ could not be found. Skipping.”, exception -> null]

 怎么解决上面的警告
 方法一:         加入找不到报警的文件                          

在resources文件下加mchange-log.properties配置文件里面内容为

com.mchange.v2.log.MLog=com.mchange.v2.log.FallbackMLog 
com.mchange.v2.log.FallbackMLog.DEFAULT_CUTOFF_LEVEL=OFF
方法二:		更换连接池
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
    <contextName>logback</contextName>

    <property name="log.path" value="${user.dir}/logs"/>

    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <target>System.out</target>
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] -| %-5level %logger{40}-%msg%n</Pattern>
        </encoder>
    </appender>

    <!-- 错误日志 一天产生一个日志文件,且只保存最近30天的日志文件,如果当前文件超过10M就进行分割-->
    <appender name="ERROR_FILE_DAILY_ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${log.path}//error.log</file>
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] -| %-5level %logger{40} - %msg%n</Pattern>
        </encoder>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <maxHistory>30</maxHistory>
            <fileNamePattern>${log.path}/error/%d.%i.log</fileNamePattern>
            <maxFileSize>10MB</maxFileSize>
        </rollingPolicy>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>error</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>
    </appender>


    <appender name="DBAppender" class="ch.qos.logback.classic.db.DBAppender">
        <!-- 使用druid连接池-->
        <connectionSource class="ch.qos.logback.core.db.DataSourceConnectionSource">
            <dataSource class="com.alibaba.druid.pool.DruidDataSource">
                <driverClassName>com.mysql.jdbc.Driver</driverClassName>
                <url>jdbc:mysql://47.101.xxx.xxx:3306/xy-pay-risk?autoReconnect=true&amp;failOverReadOnly=false&amp;allowMultiQueries=true&amp;useSSL=false</url>
                <username>root</username>
                <password>Xykjxxx</password>
                <!-- 连接名称-->
                <name>logback</name>
                <!-- initialSize :初始化时获取三个连接,取值应在minIdle与maxIdle之间。 -->
                <initialSize>3</initialSize>
                <!-- minIdle、最小连接数 -->
                <minIdle>1</minIdle>
                <!-- maxIdle、最大连接数 -->
                <maxIdle>10</maxIdle>
                <!-- 最大并发连接-->
                <maxActive>10</maxActive>
                <!--maxWait:配置获取连接等待超时的时间 ,单位是毫秒-->
                <maxWait>60000</maxWait>
                <!--配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒-->
                <timeBetweenEvictionRunsMillis>60000</timeBetweenEvictionRunsMillis>
                <!-- 超过时间限制是否回收 -->
                <removeAbandoned>true</removeAbandoned>
                <!-- 连接泄漏回收参数,单位是秒 180秒,泄露的连接可以被删除的超时值 。180秒=3分钟 -->
                <removeAbandonedTimeout>180</removeAbandonedTimeout>
            </dataSource>
        </connectionSource>

        <!-- 使用c3p0连接池-->
<!--        <connectionSource class="ch.qos.logback.core.db.DataSourceConnectionSource">-->
<!--            <dataSource class="com.mchange.v2.c3p0.ComboPooledDataSource">-->
<!--                <driverClass>com.mysql.jdbc.Driver</driverClass>-->
<!--                <jdbcUrl>jdbc:mysql://47.101.xxx.xxx:3306/xy-pay-risk?autoReconnect=true&amp;failOverReadOnly=false&amp;allowMultiQueries=true&amp;useSSL=false</jdbcUrl>-->
<!--                <user>root</user>-->
<!--                <password>Xykjxxx</password>-->
<!--                &lt;!&ndash;initialPoolSize:初始化时获取三个连接,取值应在minPoolSize与maxPoolSize之间。 &ndash;&gt;-->
<!--                <initialPoolSize>3</initialPoolSize>-->
<!--                &lt;!&ndash;minPoolSize 最小连接数&ndash;&gt;-->
<!--                <minPoolSize>1</minPoolSize>-->
<!--                &lt;!&ndash;maxPoolSize:连接池中保留的最大连接数。 &ndash;&gt;-->
<!--                <maxPoolSize>10</maxPoolSize>-->
<!--                &lt;!&ndash;maxIdleTime:最大空闲时间,60秒内未使用则连接被丢弃。若为0则永不丢弃。&ndash;&gt;-->
<!--                <maxIdleTime>60</maxIdleTime>-->
<!--                &lt;!&ndash;maxStatements:最大链接数。&ndash;&gt;-->
<!--                <maxStatements>100</maxStatements>-->
<!--                &lt;!&ndash;idleConnectionTestPeriod:每60秒检查所有连接池中的空闲连接。&ndash;&gt;-->
<!--                <idleConnectionTestPeriod>60</idleConnectionTestPeriod>-->
<!--            </dataSource>-->
<!--        </connectionSource>-->
        <filter class="com.xy.common.logback.LogLevelFilter">
            <greaterThan>info</greaterThan>
        </filter>
    </appender>

    <logger name="com.xy" level="warn"/>


    <logger name="com.xy.pay.risk.web.listener.SpringStartListener" level="info" additivity="false">
        <appender-ref ref="STDOUT"/>
    </logger>

    <logger name="com.xy.pay.risk.web.listener.SpringStopListener" level="info" additivity="false">
        <appender-ref ref="STDOUT"/>
    </logger>

    <root>
        <level value="error"/>
        <appender-ref ref="ERROR_FILE_DAILY_ROLLING"/>
        <appender-ref ref="DBAppender"/>
    </root>

</configuration>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值