我按照其站点上的说明配置了Spring Boot starter P6Spy装饰器:
## p6spy ###
# Register P6LogFactory to log JDBC events
decorator.datasource.p6spy.enable-logging=true
decorator.datasource.datasource-proxy.query.log-level=debug
decorator.datasource.datasource-proxy.slow-query.enable-logging=true
decorator.datasource.datasource-proxy.slow-query.log-level=warn
decorator.datasource.datasource-proxy.slow-query.logger-name=
# 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]
decorator.datasource.p6spy.logging=slf4j
# Log file to use (only with logging=file)
decorator.datasource.p6spy.log-file=spy.log
# Custom log format, if specified com.p6spy.engine.spy.appender.CustomLineFormat will be used with this log format
decorator.datasource.p6spy.log-format=
<dependency>
<groupId>com.github.gavlyukovskiy</groupId>
<artifactId>p6spy-spring-boot-starter</artifactId>
<version>1.5.8</version>
</dependency>
但仅从p6spy获得空输出:
2019-12-24 16:22:13.103 DEBUG 11672 --- [ntainer#0-0-C-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL query
2019-12-24 16:22:13.103 DEBUG 11672 --- [ntainer#0-0-C-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [SELECT COMIT_ID FROM DPL_PARTY.USR_DTL WHERE INDVDL_ID = (SELECT INDVDL_ID FROM DPL_PARTY.INDVDL_TLCMMNCTN WHERE EML_VAL = ?)]
2019-12-24 16:22:13.181 INFO 11672 --- [ntainer#0-0-C-1] p6spy :
2019-12-24 16:22:13.182 DEBUG 11672 --- [ntainer#0-0-C-1] c.s.a.repository.UserRepository : Obtained comitId=XBBKRHL for email of [email protected] from the DB.
2019-12-24 16:22:13.286 INFO 11672 --- [ntainer#0-0-C-1] p6spy :
查询本身执行良好。我在这里想念什么?谢谢。
最佳答案
尝试忽略日志格式的空配置:
# Custom log format, if specified com.p6spy.engine.spy.appender.CustomLineFormat will be used with this log format
# decorator.datasource.p6spy.log-format=
我认为,如果您具有不带值的属性,则它将作为空字符串传递。