Log4j打印JdbcTemplate及参数
2015-06-18 17:34
309 查看
项目中使用JdbcTemplate进行DAO层封装,有时需要调试查看SQL语句及参数
首先是SQL语句:
查看了JdbcTemplate的反编译源码,发现打印语句的地方,其日志级别为debug,
因此,添加log4j参数:log4j.logger.org.springframework.jdbc.core.JdbcTemplate=debug
其后是语句参数:
同样跟踪执行praparedStatement执行过程,添加参数:log4j.logger.org.springframework.jdbc.core.StatementCreatorUtils=debug
最终效果:
17:05:26,034 DEBUG JdbcTemplate:574 - Executing prepared SQL statement [select * from A WHERE ID=?]
17:05:26,459 DEBUG StatementCreatorUtils:207 - Setting SQL statement parameter value: column index 1, parameter value [1111], value class [java.lang.String], SQL type 12
首先是SQL语句:
查看了JdbcTemplate的反编译源码,发现打印语句的地方,其日志级别为debug,
因此,添加log4j参数:log4j.logger.org.springframework.jdbc.core.JdbcTemplate=debug
public int update(String sql) throws DataAccessException { Assert.notNull(sql, "SQL must not be null"); if (this.logger.isDebugEnabled()) { this.logger.debug("Executing SQL update [" + sql + "]"); }
其后是语句参数:
同样跟踪执行praparedStatement执行过程,添加参数:log4j.logger.org.springframework.jdbc.core.StatementCreatorUtils=debug
最终效果:
17:05:26,034 DEBUG JdbcTemplate:574 - Executing prepared SQL statement [select * from A WHERE ID=?]
17:05:26,459 DEBUG StatementCreatorUtils:207 - Setting SQL statement parameter value: column index 1, parameter value [1111], value class [java.lang.String], SQL type 12
相关文章推荐
- JVM 、JDK(c/c++)源代码下载
- 函数对象
- 怎样在Windows系统中获取开源软件SVN更多的Revision记录
- 容器set和multiset
- apk分析环境搭建
- centos 安装完Nginx后,为什么访问不了?
- 项目杂记三
- Mysql导出表结构及表数据 mysqldump用法
- centos 安装完Nginx后,为什么访问不了?
- 【弱省胡策】Round #5 Construct 解题报告
- 启用 TStringGrid 的自画功能,并避免重影
- server 2008 AD的迁移的反思
- SAT阅读高分指南(6):社科类阅读-4
- 重写HashPartitioner类
- Skype for Business MVA在线课堂
- linux 调度执行 每个月月末某个时间点执行
- opencv cvPyrDown cvPyrUp 缩放一半尺寸
- 优秀的第三方框架
- 爱情第二课,择爱两大误区
- 遮住层