From 4dc1d81f093dec79ea18d3a7f73c676b41073293 Mon Sep 17 00:00:00 2001 From: lijiarao Date: Mon, 28 Aug 2023 11:50:06 +0800 Subject: [PATCH] add p6spy --- jero-boot-base/jero-boot-base-core/pom.xml | 5 +- jero-boot-single-startup/pom.xml | 4 + .../src/main/resources/application-dev.yml | 12 +- .../src/main/resources/logback-spring.xml | 171 +++++++++--------- .../src/main/resources/spy.properties | 22 +++ pom.xml | 5 + 6 files changed, 127 insertions(+), 92 deletions(-) create mode 100644 jero-boot-single-startup/src/main/resources/spy.properties diff --git a/jero-boot-base/jero-boot-base-core/pom.xml b/jero-boot-base/jero-boot-base-core/pom.xml index 97cb9667..171bf055 100644 --- a/jero-boot-base/jero-boot-base-core/pom.xml +++ b/jero-boot-base/jero-boot-base-core/pom.xml @@ -222,7 +222,10 @@ com.squareup.okhttp3 okhttp - + + p6spy + p6spy + \ No newline at end of file diff --git a/jero-boot-single-startup/pom.xml b/jero-boot-single-startup/pom.xml index 1601a313..eae734b3 100644 --- a/jero-boot-single-startup/pom.xml +++ b/jero-boot-single-startup/pom.xml @@ -58,6 +58,10 @@ + + p6spy + p6spy + diff --git a/jero-boot-single-startup/src/main/resources/application-dev.yml b/jero-boot-single-startup/src/main/resources/application-dev.yml index 9d9498cf..24f19f73 100644 --- a/jero-boot-single-startup/src/main/resources/application-dev.yml +++ b/jero-boot-single-startup/src/main/resources/application-dev.yml @@ -141,15 +141,15 @@ spring: poolPreparedStatements: true maxPoolPreparedStatementPerConnectionSize: 20 # 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙 - filters: stat,wall,slf4j + filters: stat,slf4j # 通过connectProperties属性来打开mergeSql功能;慢SQL记录 connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000;druid.stat.logSlowSql\=true datasource: master: - url: jdbc:mysql://10.10.10.44:3306/laws-sinotruk?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true + url: jdbc:p6spy:mysql://10.10.10.44:3306/laws-sinotruk?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true username: root password: hzwlsoft.com - driver-class-name: com.mysql.cj.jdbc.Driver + driver-class-name: com.p6spy.engine.spy.P6SpyDriver # url: jdbc:mysql://127.0.0.1:3306/jero-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai # username: root # password: 123456 @@ -203,11 +203,11 @@ mybatis-plus: id-type: ASSIGN_ID # 默认数据库表下划线命名 table-underline: true - configuration: +# configuration: # 这个配置会将执行的sql打印出来,在开发或测试的时候可以用 - log-impl: org.apache.ibatis.logging.stdout.StdOutImpl +# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 返回类型为Map,显示null对应的字段 - call-setters-on-nulls: true +# call-setters-on-nulls: true #jero专用配置 jero: # 签名密钥串(前后端要一致,正式发布请自行修改) diff --git a/jero-boot-single-startup/src/main/resources/logback-spring.xml b/jero-boot-single-startup/src/main/resources/logback-spring.xml index 6611fcc3..412c90cc 100644 --- a/jero-boot-single-startup/src/main/resources/logback-spring.xml +++ b/jero-boot-single-startup/src/main/resources/logback-spring.xml @@ -14,7 +14,8 @@ - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %highlight(%-5level) %cyan(%logger{50}:%L) - %msg%n + %d{yyyy-MM-dd HH:mm:ss.SSS} %magenta([%thread]) %highlight(%-5level) \(%F:%L\) - %msg%n + UTF-8 @@ -26,7 +27,7 @@ ${LOG_HOME}/${PROJECT_NAME}/${LOG_HOME_SYSTEM}/${PROJECT_NAME}-%d{yyyy-MM-dd}.%i.log 30 - 100MB + 10MB @@ -36,93 +37,93 @@ - - - - ERROR - ACCEPT - DENY - - - - ${LOG_HOME}/${PROJECT_NAME}/${LOG_HOME_SYSTEM}/${PROJECT_NAME}-error.%d{yyyy-MM-dd}.%i.log - - 30 - - 100MB - + + + + + + + + + + + + + + + - - - [%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] [%-5level] %logger{50} - %msg%n - UTF-8 - - + + + + + + - - - - /${PROJECT_NAME}/${LOG_HOME_SYSTEM}/${PROJECT_NAME}-%d{yyyy-MM-dd}.%i.html - - 30 - 100MB - - - - %p%d%msg%M%F{32}%L - - - + + + + + + + + + + + + + + - - - - INFO - ACCEPT - DENY - - - - ${LOG_HOME}/${PROJECT_NAME}/${LOG_HOME_DRUID}/${PROJECT_NAME}.druid_info.%d{yyyy-MM-dd}.%i.log - - 15 - - 100MB - + + + + + + + + + + + + + + + - - - [%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] [%-5level] %logger{50} - %msg%n - UTF-8 - - + + + + + + - - - WARN - + + + + - - - ${LOG_HOME}/${PROJECT_NAME}/${LOG_HOME_DRUID}/${PROJECT_NAME}.druid_warn.%d{yyyy-MM-dd}.%i.log - - 30 - - 100MB - - + + + + + + + + + - - - [%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] [%-5level] %logger{50} - %msg%n - UTF-8 - - + + + + + + @@ -130,20 +131,20 @@ - - - + + + - - - + + + - - + + \ No newline at end of file diff --git a/jero-boot-single-startup/src/main/resources/spy.properties b/jero-boot-single-startup/src/main/resources/spy.properties new file mode 100644 index 00000000..9729a9b1 --- /dev/null +++ b/jero-boot-single-startup/src/main/resources/spy.properties @@ -0,0 +1,22 @@ +module.log=com.p6spy.engine.logging.P6LogFactory,com.p6spy.engine.outage.P6OutageFactory +# 使用日志系统记录sql +appender=com.p6spy.engine.spy.appender.Slf4JLogger +# 是否开启日志过滤 默认false, 这项配置是否生效前提是配置了 include/exclude/sqlexpression +filter=true +## 过滤 Log 时所排除的表名列表,以逗号分隔。 +exclude=QRTZ_SCHEDULER_STATE,QRTZ_TRIGGERS,QRTZ_LOCKS,QRTZ_FIRED_TRIGGERS,dual,QRTZ_CRON_TRIGGERS,QRTZ_JOB_DETAILS,QRTZ_CRON_TRIGGERS,QRTZ_PAUSED_TRIGGER_GRPS +## 配置记录Log例外,可去掉的结果集有error,info,batch,debug,statement,commit,rollback,result,resultset. +excludecategories=info,debug,result,commit,resultset +# 设置使用p6spy driver来做代理 +deregisterdrivers=true +# 日期格式 +dateformat=yyyy-MM-dd HH:mm:ss +databaseDialectTimestampFormat = yyyy-MM-dd HH:mm:ss +# 实际驱动 +driverlist=com.mysql.cj.jdbc.Driver +# 是否开启慢SQL记录 +outagedetection=true +# 慢SQL记录标准 秒 +outagedetectioninterval=2 +# mybatisplus自定义日志打印 +logMessageFormat=com.baomidou.mybatisplus.extension.p6spy.P6SpyLogger \ No newline at end of file diff --git a/pom.xml b/pom.xml index c8aad5a9..f1226fa4 100644 --- a/pom.xml +++ b/pom.xml @@ -308,6 +308,11 @@ spire.office.free 5.3.1 + + p6spy + p6spy + 3.9.1 +