zoukankan      html  css  js  c++  java
  • log4j2打印jdbcTemplate的sql以及参数

    log4j2打印jdbcTemplate的sql以及参数

     

    摘要: log4j2打印jdbcTemplate的sql以及参数。

    在log4j2.xml加上这两个logger即可:

    <Logger name="org.springframework.jdbc.core" level="debug"/>
    <Logger name="org.springframework.jdbc.core.StatementCreatorUtils" level="trace"/>

    Logger解释:

    org.springframework.jdbc.core包下面的所有类,输出debug级别的日志
    其中,org.springframework.jdbc.core包下面的StatementCreatorUtils类,输出trace级别的日志

    打印的内容:

    2018-10-10 15:52:16.458 DEBUG 45116 --- [e-nio-81-exec-5] o.s.j.c.JdbcTemplate                     : Executing prepared SQL statement [select * from t_user where username = ? and state = ?]
    2018-10-10 15:52:16.459 TRACE 45116 --- [e-nio-81-exec-5] o.s.j.c.StatementCreatorUtils        : Setting SQL statement parameter value: column index 1, parameter value [admin], value class [java.lang.String], SQL type unknown
    2018-10-10 15:52:16.459 TRACE 45116 --- [e-nio-81-exec-5] o.s.j.c.StatementCreatorUtils        : Setting SQL statement parameter value: column index 2, parameter value [1], value class [java.lang.Integer], SQL type unknown

    打印内容解释:

    第一行是sql,值为select * from t_user where username = ? and state = ?
    第二行是sql的第一个参数,值为admin,Java类型为String,sql类型为未知
    第三行是sql的第二个参数,值为1,Java类型为Integer,sql类型为未知

  • 相关阅读:
    假如
    Find the peace with yourself
    Sep 15th 2018
    Sep 10th 2018
    third party sales process 继续说
    成功设置open live writer
    sublime text2 基本配置及结合Python 环境
    Compmgmtlauncher.exe问题解决方法
    nginx 代理服务器
    vmware之linux不重启添加虚拟硬盘
  • 原文地址:https://www.cnblogs.com/liangweiping/p/9767058.html
Copyright © 2011-2022 走看看