从第3方jar抑制Java util日志记录 [英] Suppress java util logging from 3rd party jar
问题描述
我从Eclipse控制台中的第3方jar中获取了大量的信息日志消息.打开罐子,我看到它使用了java.util.logging.我想将其jar的输出级别设置为警告".
I am getting tons of info log messages from a 3rd party jar in my eclipse console. Cracking open the jar I see that it uses java.util.logging. I would like to set the output level for their jar to WARNING.
我尝试使用-Djava.util.logging.config.file = pathToMy/JUL.properties的VM参数 文件内容在哪里:
I have tried using the VM argument of -Djava.util.logging.config.file=pathToMy/JUL.properties where the contents of the file are:
handlers=java.util.logging.ConsoleHandler
.level=WARNING
java.util.logging.ConsoleHandler.level=WARNING
不幸的是,这并没有影响输出.
Unfortunately, that made no difference in the output.
如果更简单,我的应用程序将使用SLF4J.因此,如果有使用其他日志记录机制的简单答案,我可以切换绑定以使用它.
If it makes it any easier, my application uses SLF4J. So if there's a simple answer using a different logging mechanism I can just switch my binding to use it.
推荐答案
您是否使用过
您还可以添加以下代码来检查您的配置文件是否正常工作: You can also add the following code to check that your config file is working: 这篇关于从第3方jar抑制Java util日志记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
public static void main(String[] arg) throws Exception {
String p = System.getProperty("java.util.logging.config.file");
System.out.println(p);
System.out.println(new File(p).length());
System.out.println(Logger.getLogger("").getLevel());
}