Search code examples
springspring-bootjooq

Spring JOOQ - Remove Fetched result from console


I already went through link: JOOQ with Logback and but I am looking Fetched result from the logs. I only wanted to keep the

  1. Executing query.

  2. Remove JOOQ Logo, just show version.

Error:

2019-12-24 10:11:13.500  INFO 8944 --- [nio-8080-exec-1] org.jooq.Constants                       : 

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@  @@        @@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@        @@@@@@@@@@
@@@@@@@@@@@@@@@@  @@  @@    @@@@@@@@@@
@@@@@@@@@@  @@@@  @@  @@    @@@@@@@@@@
@@@@@@@@@@        @@        @@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@        @@        @@@@@@@@@@
@@@@@@@@@@    @@  @@  @@@@  @@@@@@@@@@
@@@@@@@@@@    @@  @@  @@@@  @@@@@@@@@@
@@@@@@@@@@        @@  @  @  @@@@@@@@@@
@@@@@@@@@@        @@        @@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@  @@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  Thank you for using jOOQ 3.12.3

2019-12-24 10:11:13.539 DEBUG 8944 --- [nio-8080-exec-1] org.jooq.tools.LoggerListener            : Executing query          : select `test`.`posts`.`ID`, `test`.`posts`.`TITLE`, `test`.`posts`.`CONTENT`, `test`.`posts`.`CREATED_ON` from `test`.`posts`
2019-12-24 10:11:13.605 DEBUG 8944 --- [nio-8080-exec-1] org.jooq.tools.LoggerListener            : Fetched result           : +----+------+--------------+---------------------+
2019-12-24 10:11:13.606 DEBUG 8944 --- [nio-8080-exec-1] org.jooq.tools.LoggerListener            :                          : |  ID|TITLE |CONTENT       |CREATED_ON           |
2019-12-24 10:11:13.606 DEBUG 8944 --- [nio-8080-exec-1] org.jooq.tools.LoggerListener            :                          : +----+------+--------------+---------------------+
2019-12-24 10:11:13.606 DEBUG 8944 --- [nio-8080-exec-1] org.jooq.tools.LoggerListener            :                          : |   1|Post 1|This is post 1|2020-01-03 00:00:00.0|
2019-12-24 10:11:13.606 DEBUG 8944 --- [nio-8080-exec-1] org.jooq.tools.LoggerListener            :                          : |   2|Post 2|This is post 2|2020-01-05 00:00:00.0|
2019-12-24 10:11:13.606 DEBUG 8944 --- [nio-8080-exec-1] org.jooq.tools.LoggerListener            :                          : |   3|Post 3|This is post 3|2020-01-07 00:00:00.0|
2019-12-24 10:11:13.606 DEBUG 8944 --- [nio-8080-exec-1] org.jooq.tools.LoggerListener            :                          : +----+------+--------------+---------------------+
2019-12-24 10:11:13.606 DEBUG 8944 --- [nio-8080-exec-1] org.jooq.tools.LoggerListener            : Fetched row(s)           : 3
2019-12-24 10:11:13.624 DEBUG 8944 --- [nio-8080-exec-1] o.s.w.s.m.m.a.HttpEntityMethodProcessor  : Using 'application/json', given [*/*] and supported [application/json, application/*+json, application/json, application/*+json]
2019-12-24 10:11:13.624 DEBUG 8944 --- [nio-8080-exec-1] o.s.w.s.m.m.a.HttpEntityMethodProcessor  : Writing [[Post [id=1, title=Post 1, content=This is post 1, createdOn=2020-01-03 00:00:00.0], Post [id=2, tit (truncated)...]
2019-12-24 10:11:13.657 DEBUG 8944 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed 200 OK

application.properties for reference

spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/test
spring.datasource.username=root
spring.datasource.password=root

spring.jooq.sql-dialect=MYSQL

#spring.datasource.initialization-mode=always
spring.datasource.continueOnError=true

logging.level.org.springframework.web=DEBUG
logging.level.org.jooq.*=DEBUG

Solution

  • Turning off logging of the logo

    The answer to removing the logo from your logs has been given here. There are several ways. One is to use this system property:

    -Dorg.jooq.no-logo=true
    

    Another option with Logback is given in this answer by flamezealot:

    <logger name="org.jooq.Constants" level="warn">
            <appender-ref ref="STDOUT" />
    </logger>
    

    Turning off logging of results

    Execution logging is documented here. You can turn it off using

    Settings settings = new Settings()
        .withExecuteLogging(false);
    

    Pass those settings to your Configuration. For the latter, you can also turn off DEBUG logging for jOOQ:

    logging.level.org.jooq.*=INFO