Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable JooQ's self-ad message in 3.4+?

Tags:

java

logging

jooq

I'm a big fan of JooQ, but unfortunately since upgrading from 3.3 it prints a very annoying message to the console each time before my code exits:

Feb 02, 2015 7:28:06 AM org.jooq.tools.JooqLogger info
INFO: 

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
<snip>
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  Thank you for using jOOQ 3.5.1

Unfortunately I cannot manage to remove this log at all.

Note that I don't use slf4j, nor log4j nor any log API; therefore the only mechanism I have available is j.u.l.

I have tried to disable it completely using this:

static {
    Stream.of(Logger.getAnonymousLogger(), Logger.getGlobal(),
        Logger.getLogger("org.jooq.tools.JooqLogger")
    ).forEach(l -> {
        l.setLevel(Level.OFF);
        final Handler[] handlers = l.getHandlers();
        Arrays.stream(handlers).forEach(l::removeHandler);
    });
}

Unfortunatley, it doesn't work, the message still appears.

How do I make this message disappear short of modifying the code, which I want to avoid here?

like image 784
fge Avatar asked Feb 02 '15 06:02

fge


4 Answers

This seems to work for me:

static {
    LogManager.getLogManager().reset();
}

This is also indicated as a solution a couple of times in this Stack Overflow question.

Note that version 3.6+ will also ship with a system property that can be used to deactivate displaying this logo:

-Dorg.jooq.no-logo=true
like image 55
Lukas Eder Avatar answered Nov 15 '22 03:11

Lukas Eder


On v3.6 and higher you can do:

System.setProperty("org.jooq.no-logo", "true");
like image 45
mevdschee Avatar answered Nov 15 '22 02:11

mevdschee


That message is located in the org.jooq.impl.DefaultRenderContext source file and it is using the org.jooq.Constants logger. Here is the relevant source code:

    /* [trial] */ 
    JooqLogger l = JooqLogger.getLogger(Constants.class); 
    String message;
    message = "Thank you for using jOOQ " + Constants.FULL_VERSION;

    /* [pro] xx 
    xxxxxxx x xxxxxx xxx xxx xxxxx xxx xx xxx xxxx xxxx x x xxxxxxxxxxxxxxxxxxxxxx x x xxxxx xxxxxxxxx 
    xx [/pro] */ 

Looks like the message is generated because you are using a trial version. I would assume that upgrading to the pro version would disable the message. What else could be better way to show that you are a big fan of the project?

Otherwise, if you can live with the guilt and shame, you could disable info messages from the org.jooq.Constants logger by setting the level to WARNING.

This can be done adding the following to your logging.properties:

#ThanksNoThanks
org.jooq.Constants.level=WARNING

Or in Java code by calling the following methods:

//SorryNotSorry
private static final JOOQ_AD_LOGGER = Logger.getLogger("org.jooq.Constants");
static {
   JOOQ_AD_LOGGER.setLevel(Level.WARNING);
}

Make sure you stay in compliance with your jOOQ License and Maintenance Agreement:

jOOQ License and Maintenance Agreement: 
* ----------------------------------------------------------------------------- 
* Data Geekery grants the Customer the non-exclusive, timely limited and 
* non-transferable license to install and use the Software under the terms  of 
* the jOOQ License and Maintenance Agreement. 
* 
* This library is distributed with a LIMITED WARRANTY. See the jOOQ License 
* and Maintenance Agreement for more details: http://www.jooq.org/licensing 
*/ 
like image 9
jmehrens Avatar answered Nov 15 '22 02:11

jmehrens


In case you are using org.slf4j.Logger for logging, in your resources/logback.xml you may add something like that

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

like image 4
mcfan Avatar answered Nov 15 '22 04:11

mcfan