如何打印完整的MYSQL带参数SQL日志信息

在mysql的jdbc中开启sql分析,如下:

jdbc.url=jdbc:mysql://127.0.0.1/test?useUnicode=true&characterEncoding=UTF-8&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&logger=com.mysql.jdbc.log.Slf4JLogger&profileSQL=true

如此便可以生成完整的SQL信息

[-- ::,] INFO com.mysql.jdbc.log.Slf4JLogger.logInfo(Slf4JLogger.java:) - FETCH created: Tue Aug  :: CST  duration:  connection:  statement:  resultset:
[-- ::,] INFO com.mysql.jdbc.log.Slf4JLogger.logInfo(Slf4JLogger.java:) - QUERY created: Tue Aug :: CST duration: connection: statement: resultset: message: update item_costs set num_iid= where id=
[-- ::,] INFO com.mysql.jdbc.log.Slf4JLogger.logInfo(Slf4JLogger.java:) - FETCH created: Tue Aug :: CST duration: connection: statement: resultset:
[-- ::,] INFO com.mysql.jdbc.log.Slf4JLogger.logInfo(Slf4JLogger.java:) - QUERY created: Tue Aug :: CST duration: connection: statement: resultset: message: select @@session.tx_read_only
[-- ::,] INFO com.mysql.jdbc.log.Slf4JLogger.logInfo(Slf4JLogger.java:) - FETCH created: Tue Aug :: CST duration: connection: statement: resultset:
[-- ::,] INFO com.mysql.jdbc.log.Slf4JLogger.logInfo(Slf4JLogger.java:) - QUERY created: Tue Aug :: CST duration: connection: statement: resultset: message: update skus set num_iid= where id=
[

https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-configuration-properties.html

上一篇:C#添加错误日志信息


下一篇:MySQL提供的错误日志中的错误级别一共有3个分别为: