首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何在3.4+中关闭JooQ的自广告消息?

如何在3.4+中关闭JooQ的自广告消息?
EN

Stack Overflow用户
提问于 2015-02-02 14:35:03
回答 6查看 9K关注 0票数 36

我是JooQ的铁杆粉丝,但不幸的是,自从从3.3升级以来,每次在我的代码退出之前,它都会向控制台打印一条非常恼人的消息:

代码语言:javascript
复制
Feb 02, 2015 7:28:06 AM org.jooq.tools.JooqLogger info
INFO: 

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

不幸的是,我根本无法删除这个日志。

请注意,我既不使用slf4j,也不使用log4j,也不使用任何log API;因此,我唯一可用的机制是j.u.l。

我已经尝试使用以下命令完全禁用它:

代码语言:javascript
复制
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);
    });
}

不幸的是,它不工作,消息仍然出现。

如果不修改代码,我该如何让这条消息消失呢?

EN

回答 6

Stack Overflow用户

回答已采纳

发布于 2015-02-03 01:41:04

这似乎对我很有效:

代码语言:javascript
复制
static {
    LogManager.getLogManager().reset();
}

这也被指定为解决方案a couple of times in this Stack Overflow question

请注意,3.6+版本还将附带system property that can be used to deactivate displaying this logo

代码语言:javascript
复制
-Dorg.jooq.no-logo=true
票数 28
EN

Stack Overflow用户

发布于 2018-01-11 06:31:10

在v3.6和更高版本中,您可以执行以下操作:

代码语言:javascript
复制
System.getProperties().setProperty("org.jooq.no-logo", "true");
票数 20
EN

Stack Overflow用户

发布于 2015-02-02 23:01:30

该消息位于org.jooq.impl.DefaultRenderContext源文件中,并且正在使用org.jooq.Constants记录器。相关源码如下:

代码语言:javascript
复制
    /* [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] */ 

看起来消息是因为您使用的是试用版而生成的。我假设升级到pro版本会禁用该消息。还有什么更好的方式来表明你是这个项目的铁杆粉丝?

否则,如果您可以忍受guilt and shame,您可以通过将级别设置为WARNING来禁用来自org.jooq.Constants记录器的info消息。

这可以通过将以下内容添加到您的logging.properties来完成:

代码语言:javascript
复制
#ThanksNoThanks
org.jooq.Constants.level=WARNING

或者在Java代码中调用以下方法:

代码语言:javascript
复制
//SorryNotSorry
private static final JOOQ_AD_LOGGER = Logger.getLogger("org.jooq.Constants");
static {
   JOOQ_AD_LOGGER.setLevel(Level.WARNING);
}

确保您遵守您的jOOQ许可和维护协议:

代码语言:javascript
复制
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 
*/ 
票数 8
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28272284

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档