我是JooQ的铁杆粉丝,但不幸的是,自从从3.3升级以来,每次在我的代码退出之前,它都会向控制台打印一条非常恼人的消息:
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。
我已经尝试使用以下命令完全禁用它:
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);
});
}
不幸的是,它不工作,消息仍然出现。
如果不修改代码,我该如何让这条消息消失呢?
发布于 2015-02-03 01:41:04
这似乎对我很有效:
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
-Dorg.jooq.no-logo=true
发布于 2018-01-11 06:31:10
在v3.6和更高版本中,您可以执行以下操作:
System.getProperties().setProperty("org.jooq.no-logo", "true");
发布于 2015-02-02 23:01:30
该消息位于org.jooq.impl.DefaultRenderContext源文件中,并且正在使用org.jooq.Constants记录器。相关源码如下:
/* [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来完成:
#ThanksNoThanks
org.jooq.Constants.level=WARNING
或者在Java代码中调用以下方法:
//SorryNotSorry
private static final JOOQ_AD_LOGGER = Logger.getLogger("org.jooq.Constants");
static {
JOOQ_AD_LOGGER.setLevel(Level.WARNING);
}
确保您遵守您的jOOQ许可和维护协议:
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
*/
https://stackoverflow.com/questions/28272284
复制相似问题