Search code examples
javaspring-bootloggingspring-data-jpap6spy

P6Spy Spring Boot starter decorator produces empty output


I configured a Spring Boot starter P6Spy decorator as per the instructions on their site:

## 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>

but getting only empty output from 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                                    : 

The query themselves execute fine. What am I missing here? Thanks.


Solution

  • Try to leave out the empty configuration for the log format:

    # Custom log format, if specified com.p6spy.engine.spy.appender.CustomLineFormat will be used with this log format
    # decorator.datasource.p6spy.log-format=
    

    I think if you have the property without a value, it will be passed as an empty string.