Skip to content

Commit

Permalink
Merge pull request #340 from insist-learning/patch-1
Browse files Browse the repository at this point in the history
Update 06.执行SQL分析打印.md
  • Loading branch information
qmdx authored Oct 10, 2023
2 parents 6291571 + 511a0fe commit 543f2af
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions docs/01.指南/03.扩展/06.执行SQL分析打印.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,39 @@ outagedetection=true
# 慢SQL记录标准 2 秒
outagedetectioninterval=2
```
- springboot 集成方式
官方文档:https://github.com/gavlyukovskiy/spring-boot-data-source-decorator

依赖:
```xml
<dependency>
<groupId>com.github.gavlyukovskiy</groupId>
<artifactId>p6spy-spring-boot-starter</artifactId>
<version>1.9.0</version>
</dependency>
```
配置:

```
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 注意!

Expand Down

0 comments on commit 543f2af

Please sign in to comment.