通过Spring内部日志查看数据库连接创建释放情况或者其他Spring内部的信息,如缓存池的使用等...

logback.xml,logback-test.xml同时存在时,默认起作用的配置是logback-test.xml,发布到生产库时,不上传logback-test.xml,那么起作用的日志配置文件是logback.xml

把日志文件logback.xml的日志级别调整为debug

<root level="debug">

spring会输出内部的日志消息,如建立连接池,取得连接,释放连接等等 如下

DEBUG org.springframework.jdbc.datasource.DataSourceTransactionManager - Creating new transaction with name [com.mycompany.project.service.XXXService.getYYY: PROPAGATION_REQUIRED,ISOLATION_DEFAULT,readOnly
DEBUG org.springframework.jdbc.datasource.DataSourceTransactionManager - Acquired Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@1d59cc2] for JDBC transaction
DEBUG org.springframework.jdbc.datasource.DataSourceUtils - Setting JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@1d59cc2] read-only
DEBUG org.springframework.jdbc.datasource.DataSourceTransactionManager - Switching JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@1d59cc2] to manual commit
DEBUG org.springframework.jdbc.datasource.DataSourceTransactionManager - Initiating transaction commit
DEBUG org.springframework.jdbc.datasource.DataSourceTransactionManager - Committing JDBC transaction on Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@1d59cc2]
DEBUG org.springframework.jdbc.datasource.DataSourceUtils - Resetting read-only flag of JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@1d59cc2]
DEBUG org.springframework.jdbc.datasource.DataSourceTransactionManager - Releasing JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@1d59cc2] after transaction
DEBUG org.springframework.jdbc.datasource.DataSourceUtils - Returning JDBC Connection to DataSource

在root的日志级别高于debug时,强制要求输出debug级别的日志信息:

<logger name="com.ibatis.sqlmap.engine.cache.CacheModel" level="DEBUG" />
<logger name="com.ibatis.common.jdbc.SimpleDataSource" level="DEBUG" />
<logger name="java.sql.Connection" level="DEBUG" />
<logger name="com.ibatis" level="DEBUG" />
<logger name="com.ibatis.common.util.StopWatch" level="DEBUG" />
<logger name="java.sql.Statement" level="INFO" />
<logger name="java.sql.ResultSet" level="INFO" />
<logger name="com.ibatis.sqlmap.engine.builder.xml.SqlMapParser" level="DEBUG" />
<logger name="com.ibatis.sqlmap.engine.impl.SqlMapClientImpl" level="DEBUG" />
<logger name="java.sql.PreparedStatement" level="DEBUG" />
<logger name="org.springframework.ui.freemarker" level="DEBUG" />
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值