2010-01-13 147 views
0

我想知道如何編程關閉Java記錄 - 無屬性文件,沒有命令行參數等如何以編程方式停止java.util.logging?

我已經試過:

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())); 

但第三方庫(飛碟)不管我做什麼,都會繼續記錄所有消息。

它在生產中並不重要,但是在我的IDE中讓這些控制檯消息在整個節目中都非常煩人。 (在未來的時候,我將重定向到另一日誌框架...)

回答

3
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"); 

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

0

到尤瓦的回答相似:

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

這適用於XR (努力),但我真的在尋找神奇的關閉所有日誌記錄(雖然這對我來說很好...)

相關問題