我是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或任何日志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);
});
}
不幸的是,它不起作用,信息仍然出现。
如果不修改代码,如何使此消息消失,我想避免在这里?
答案 0 :(得分:17)
这似乎对我有用:
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
答案 1 :(得分:5)
该消息位于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] */
看起来是因为您使用的是试用版而生成了消息。我认为升级到专业版会禁用该消息。还有什么可以更好地表明你是该项目的忠实粉丝?
否则,如果您可以使用guilt and shame,则可以通过将级别设置为WARNING来禁用org.jooq.Constants记录器中的信息消息。
这可以在您的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
*/
答案 2 :(得分:4)
在v3.6及更高版本上,你可以这样做:
System.getProperties().setProperty("org.jooq.no-logo", "true");
答案 3 :(得分:1)
如果您使用org.slf4j.Logger
进行日志记录,则可以在resources/logback.xml
中添加类似内容
<logger name="org.jooq" level="warn" additivity="false">
<appender-ref ref="STDOUT" />
</logger>
答案 4 :(得分:0)
对我来说,这适用于Jooq 3.11+上的主类中的JavaFx 8
@Override
public void start(Stage primaryStage) throws Exception{
System.getProperties().setProperty("org.jooq.no-logo", "true");
///Extra code......
}
答案 5 :(得分:0)
我在我的logback-spring.xml文件中使用了original payload(88):
0x0000: 870d 1119 5a34 9d95 e597 be6a 8bc7 2037
0x0010: a1f7 ba02 1ef2 a0be de5e 5406 a5b1 0e03
0x0020: c463 c235 5c45 9b51 6734 1f28 e364 2b36
0x0030: 470b 64da bfa3 1a68 f209 94aa 44b0 9131
0x0040: ffe0 12f1 9208 3a7b aa95 da51 bafd 31cd
0x0050: 3d0a 8733 56e0 ae0d
key(16):
0x0000: 1a0f cccc 0315 2b58 1b1a 02ea 3664 485f
iv(8):
0x0000: 7a2b 37d7 160c 853c
icv(12):
0x0000: d7b5 13fe 8c5e 96d8 598d a74f
aad(8):
0x0000: c082 47f5 0000 0002
decrypted_payload(88):
0x0000: 860c 9110 87c6 db5a c40a a592 f862 b8ea
0x0010: b476 3be6 0881 06d4 ad11 eb2a 2e1c 698d
0x0020: a803 2417 8ffb 7130 444d 4fc8 b402 c602
0x0030: 1a0b 031b b89a 4ddb 707b f920 04ea 48c5
0x0040: 5424 5a9b bb34 a88a 08ee 2556 5532 3419
0x0050: 2621 19e6 f4e1 72b2
Tag Verify Failed!
,
slf4j
这行得通。