java - P6Spy Spring Boot 启动装饰器产生空输出

标签 java spring-boot logging spring-data-jpa p6spy

我配置了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 niren.sinha@bnymellon.com 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=

我认为如果您的属性没有值,它将作为空字符串传递。

关于java - P6Spy Spring Boot 启动装饰器产生空输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59474254/

相关文章:

java - 尝试保存嵌套 fragment 的状态时出现异常 [ fragment 不再存在关键 android :target_state]

java - 在插件中和通过 Tomcat 覆盖 Spring Boot application.properties 属性?

java - 创建 PDF 并将其返回到 ResponseEntity

java - log4j - 写入/记录到多个日志文件取决于应用程序

logging - Logger 和 LogWriter 的区别

java - Liferay portlet 中的自定义 servlet/jsp

机构的 Javadoc 标签

java - Solaris 上不明确的输出重定向

java - 软键盘不出现

java - MockMvc 抛出 HttpMediaTypeNotSupportedException 状态预期为 : 201 but was 415