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

别来无恙 提交于 2020-01-12 11:52:11

问题


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?


回答1:


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



回答2:


On v3.6 and higher you can do:

System.getProperties().setProperty("org.jooq.no-logo", "true");



回答3:


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 
*/ 



回答4:


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>




回答5:


This work for me on JavaFx 8 in main class on Jooq 3.11+

@Override
    public void start(Stage primaryStage) throws Exception{
     System.getProperties().setProperty("org.jooq.no-logo", "true");
     ///Extra code......

}



回答6:


I use slf4j,in my logback-spring.xml, I added:

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

This worked.



来源:https://stackoverflow.com/questions/28272284/how-to-disable-jooqs-self-ad-message-in-3-4

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!