Share jOOQ on Facebook
Share jOOQ on Twitter

All versions: 3.9 | 3.8 | 3.7 | 3.6 | 3.5 | 3.4 | 3.3 | Development versions: 3.10 | Unsupported versions: 3.2 | 3.1 | 3.0 | 2.6 | 2.5

jOOQ logs all SQL queries and fetched result sets to its internal DEBUG logger, which is implemented as an execute listener. By default, execute logging is activated in the jOOQ Settings. In order to see any DEBUG log output, put either log4j or slf4j on jOOQ's classpath along with their respective configuration. A sample log4j configuration can be seen here:

<?xml version="1.0" encoding="UTF-8"?>
    <appender name="stdout" class="org.apache.log4j.ConsoleAppender">
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%m%n" />

        <priority value="debug" />
        <appender-ref ref="stdout" />

With the above configuration, let's fetch some data with jOOQ, BOOK.TITLE).from(BOOK).orderBy(BOOK.ID).limit(1, 2).fetch();

The above query may result in the following log output:

Executing query          : select "BOOK"."ID", "BOOK"."TITLE" from "BOOK" order by "BOOK"."ID" asc limit ? offset ?
-> with bind values      : select "BOOK"."ID", "BOOK"."TITLE" from "BOOK" order by "BOOK"."ID" asc limit 2 offset 1
Query executed           : Total: 1.439ms
Fetched result           : +----+------------+
                         : |  ID|TITLE       |
                         : +----+------------+
                         : |   2|Animal Farm |
                         : |   3|O Alquimista|
                         : +----+------------+
Finishing                : Total: 4.814ms, +3.375ms

Essentially, jOOQ will log

  • The SQL statement as rendered to the prepared statement
  • The SQL statement with inlined bind values (for improved debugging)
  • The query execution time
  • The first 5 records of the result. This is formatted using jOOQ's text export
  • The total execution + fetching time

If you wish to use your own logger (e.g. avoiding printing out sensitive data), you can deactivate jOOQ's logger using your custom settings and implement your own execute listener logger.

The jOOQ Logo