开发者

How do I programatically stop java.util.logging?

I'd like to know how to programatically turn off java logging - no property files, no command line arguments etc.

I've tried:

final Properties logProperties = new Properties();
logProperties.put("handlers", "java.util.logging.MemoryHandler");
logProperties.put(".level", "SEVERE");
logProperties.put("java.util.logging.ConsoleHandler.level", "SEVERE");

final ByteArrayOutputStream bytes = new ByteArrayOutputStream();
logProperties.store(bytes, applicationName);
new String(bytes.toByteArray());
LogManager.getLogManager().readConfiguration(new ByteArrayInputStream(bytes.toByteArray()));

but the third party library (Flying Saucer) continues to log all its messages regardless of what I do.

It doesn't matter so much in production, but it is really annoying in my IDE to get these console messages all over the show. (At a fu开发者_开发技巧ture point, I shall redirect to another logging framework...)


System.setProperty("show-config", "OFF");
System.setProperty("xr.util-logging.plumbing.layout.level", "OFF");
System.setProperty("xr.util-logging.plumbing.config.level", "OFF");
System.setProperty("xr.util-logging.plumbing.load.xml-entities.level",
      "OFF");
System.setProperty("xr.util-logging.plumbing.init.level", "OFF");
System.setProperty(
        "xr.util-logging.java.util.logging.ConsoleHandler.level", "OFF");
System.setProperty("xr.util-logging.plumbing.exception.level", "OFF");
System.setProperty("xr.util-logging.plumbing.match.level", "OFF");
System.setProperty("xr.util-logging..level", "OFF");
System.setProperty("xr.util-logging.plumbing.cascade.level", "OFF");
System.setProperty("xr.util-logging.plumbing.load.level", "OFF");
System.setProperty("xr.util-logging.plumbing.css-parse.level", "OFF");
System.setProperty("xr.util-logging.plumbing.render.level", "OFF");
System.setProperty("xr.util-logging.plumbing.level", "OFF");
System.setProperty("xr.util-logging.plumbing.general.level", "OFF");

(per https://xhtmlrenderer.dev.java.net/servlets/ReadMsg?list=users&msgNo=142)


Similar to Yuval's answer:

System.setProperty("xr.util-logging.loggingEnabled", "false")

This works for xr(enderer), but I'm really on the lookout for the magic one to turn off all logging (although this is nice for me now...)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜