日期:2014-05-16  浏览次数:20445 次

通过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" />
1 楼 schoolgan 2010-11-29  
请问一下,写入数据库的数据,访问时间是一串数字来的,怎样知道访问时间日期?
2 楼 desert3 2010-11-29  
一串数字是什么意思?字段的类型是timestamp吗?是的话用下面的sql可以格式化
SELECT to_char(systimestamp,'YYYY-MM-DD HH24:MI:SS.FF3') FROM DUAL