I use springBoot with JOOQ and would like to log generated SQL's.
I added slf4J to my maven dependency and log4j.xml like in JOOQ documenation (http://www.jooq.org/doc/latest/manual/sql-execution/logging/). But when jooq executes some queries, I can not see any log in my console.
I also search for this issue in google, but I couldn't find anything. SpringBoot uses logBack, so I have logBack and slf4J in my path. Is it possible to use logBack for JOOQ ? I didnt any instruction on JOOQ Site about it.
jOOQ's built-it JooqLogger
tries to resolve an optional logger dependency in the following order:
java.util.logging
is usedSo, as soon as the JooqLogger
finds slf4j on the classpath (e.g. as a transitive dependency from spring boot), it will use that as a logging framework. This is reasonable, because slf4j can be configured to delegate to any other logging framework, including log4j and java.util.logging
.
So, in order to enable jOOQ's debug logging via logback and Spring Boot, it is sufficient to put the following logback.xml
file at your classpath root:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<logger name="org.jooq" level="DEBUG"/>
</configuration>
This is now also reflected in the jOOQ-spring-boot-example on GitHub.
Some more ideas can be found here in the Spring Boot manual: https://docs.spring.io/spring-boot/docs/current/reference/html/howto-logging.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With