From 511a0feaeb80fc25be36576c07060482ba46f97d Mon Sep 17 00:00:00 2001 From: JAVABBB <40890438+insist-learning@users.noreply.github.com> Date: Tue, 10 Oct 2023 10:09:32 +0800 Subject: [PATCH] =?UTF-8?q?Update=2006.=E6=89=A7=E8=A1=8CSQL=E5=88=86?= =?UTF-8?q?=E6=9E=90=E6=89=93=E5=8D=B0.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 增加 p6spy springboot 启动器的集成方式 --- ...06\346\236\220\346\211\223\345\215\260.md" | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git "a/docs/01.\346\214\207\345\215\227/03.\346\211\251\345\261\225/06.\346\211\247\350\241\214SQL\345\210\206\346\236\220\346\211\223\345\215\260.md" "b/docs/01.\346\214\207\345\215\227/03.\346\211\251\345\261\225/06.\346\211\247\350\241\214SQL\345\210\206\346\236\220\346\211\223\345\215\260.md" index d8191af48..50b558b67 100644 --- "a/docs/01.\346\214\207\345\215\227/03.\346\211\251\345\261\225/06.\346\211\247\350\241\214SQL\345\210\206\346\236\220\346\211\223\345\215\260.md" +++ "b/docs/01.\346\214\207\345\215\227/03.\346\211\251\345\261\225/06.\346\211\247\350\241\214SQL\345\210\206\346\236\220\346\211\223\345\215\260.md" @@ -67,6 +67,39 @@ outagedetection=true # 慢SQL记录标准 2 秒 outagedetectioninterval=2 ``` +- springboot 集成方式 + 官方文档:https://github.com/gavlyukovskiy/spring-boot-data-source-decorator + +依赖: +```xml + + com.github.gavlyukovskiy + p6spy-spring-boot-starter + 1.9.0 + +``` +配置: + +``` +decorator: + datasource: + p6spy: + # 全部可用参数参照该类:com.p6spy.engine.spy.appender.CustomLineFormat + log-format: "\ntime:%(executionTime) || sql:%(sql)\n" + # 自定义日志类的作用仅仅是改变了打印的颜色,如果不需要可以不加 + logging: custom + custom-appender-class: com.example.testinit.config.StdoutLogger +``` +```java +public class StdoutLogger extends com.p6spy.engine.spy.appender.StdoutLogger { + public StdoutLogger() { + } + + public void logText(String text) { + System.err.println(text); + } +} +``` ::: warning 注意!