简体   繁体   English

如何禁用所有 SLF4J 消息

[英]How to disable all SLF4J messages

I am writing a simple five class command line application.我正在编写一个简单的五类命令行应用程序。 I am using a serial port library jssc which has SLF4J implemented.我正在使用一个实现了 SLF4J 的串行端口库jssc Because of this I get the following text to the console:因此,我将以下文本发送到控制台:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

I have read the various questions and answers and have downloaded the slf4j-nop-1.7.9.jar which is in the class path for the project.我已经阅读了各种问题和答案,并下载了项目类路径中的slf4j-nop-1.7.9.jar

I do not want nor need logging for this application.我不想也不需要为此应用程序进行日志记录。 It runs from the command line, does its 10 seconds worth of work, and ends.它从命令行运行,执行 10 秒的工作,然后结束。 No logging required at all.根本不需要记录。 How do I get rid of even the most basic of SLF4J messages?我如何摆脱最基本的 SLF4J 消息?

BTW, I can see org.slf4j.impl.StaticLoggerBinder.class in the slf4j-nop-1.7.9.jar in the class path, yet it fails to load.顺便说一句,我可以在类路径中的slf4j-nop-1.7.9.jar中看到org.slf4j.impl.StaticLoggerBinder.class ,但它无法加载。 Why?为什么?

And finally, why is this so complex?最后,为什么这如此复杂? I just want it to shut up!我只想让它闭嘴!

Ok, I found the problem.好的,我发现了问题。 You do need the slf4j-nop-1.7.9.jar .您确实需要slf4j-nop-1.7.9.jar You also need to add the noop jar to the project Run Configuration/ Dependencies tab您还需要将 noop jar 添加到项目的 Run Configuration/Dependencies 选项卡

Sigh...叹...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM