java spring-boot-data-source-decorator与p6 spy不记录insert语句

qc6wkl3g  于 2023-11-15  发布在  Java
关注(0)|答案(2)|浏览(177)

我使用p6 spy来记录sql语句。我们使用springboot/hibernate进行Java ORMMap。我看到spy.log中只记录了select语句。当代码中执行insert语句时,我看到日志中只记录了commit语句,但没有记录insert语句。

|connection|commit||
|connection|statement | select * from emp_id where id=1234

字符串
https://github.com/gavlyukovskiy/spring-boot-data-source-decorator

# Register P6LogFactory to log JDBC events
decorator.datasource.p6spy.enable-logging=true
# Use com.p6spy.engine.spy.appender.MultiLineFormat instead of com.p6spy.engine.spy.appender.SingleLineFormat
decorator.datasource.p6spy.multiline=true
# Use logging for default listeners [slf4j, sysout, file, custom]
decorator.datasource.p6spy.logging=file
# Log file to use (only with logging=file)
decorator.datasource.p6spy.log-file=spy.log
# Class file to use (only with logging=custom). The class must implement com.p6spy.engine.spy.appender.FormattedLogger
decorator.datasource.p6spy.custom-appender-class=my.custom.LoggerClass
# Custom log format, if specified com.p6spy.engine.spy.appender.CustomLineFormat will be used with this log format
decorator.datasource.p6spy.log-format=
# Use regex pattern to filter log messages. If specified only matched messages will be logged.
decorator.datasource.p6spy.log-filter.pattern=
# Report the effective sql string (with '?' replaced with real values) to tracing systems.
# NOTE this setting does not affect the logging message.
decorator.datasource.p6spy.tracing.include-parameter-values=true

tez616oj

tez616oj1#

在配置p6 spy之前运行它:
第一个月
为什么它有效?你可能有默认情况下从日志中排除的批量更新。这个解决方案有点难看,但spring-boot-data-source-decorator目前不支持excludecatogies的配置。

oknwwptz

oknwwptz2#

我也有和你一样的问题,终于找到了解决办法。
默认情况下,p6spy会通过名为excludecategoriesspy.properties配置从日志记录中排除某些类别:info,debug,result,resultset,batch
INSERT(至少在这里)是batch类别的一部分。
在我的例子中,我在spy.properties文件中放入了下面这行:

excludecategories=

字符串
现在它打印INSERT。
该文档可在以下位置找到:https://p6spy.readthedocs.io/en/latest/configandusage.html
我找不到这个特定的属性是否可以在application.properties文件中设置。在撰写本文时,spring-boot-data-source-decorator似乎不支持它。
[]秒

相关问题