Hints and Tips

This page provides some solutions for problems we’ve encountered ourselves or have been raised on the Apache Isis mailing lists.

Tracing SQL Statements

If you want to debug the SQL being sent to the database, one approach is to use the p6spy JDBC Driver. This acts as a decorator, logging the calls and then passing through to the underlying database.

Enabling p6spy is easily done using the gavlyukovskiy/spring-boot-data-source-decorator package:

  • add the com.github.gavlyukovskiy:p6spy-spring-boot-starter dependency to your pom.xml:

        <scope>compile</scope>      (1)
    1 change to test if only using within integration tests, for example.
  • add properties to enable logging:

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

The integration makes it easy to set the most common configuration properties, but it’s also possible to configure other p6spy properties using its various configuration mechanisms; see p6spy docs for details.

Rather than adding the properties directly to application.properties, you might prefer to set up a "p6spy" profile so that the configuration can be enabled/disabled easily:

  • create a properties file for a "p6spy" profile, in either the root or config package:

  • move the configuration properties from application.properties into application-p6spy.properties

  • enable the p6spy profile using the spring.profiles.active system property: