1
我想在使用HtmlUnit時禁止Apache的HttpClient的某些日誌。我使用帶有JDK日誌記錄的HtmlUnit 2.27。每次我將'org.apache.http.wire'的級別明確設置爲Off時,HtmlUnit會將級別重置爲空。抑制HtmlUnit Apache日誌
例如:
//turn on all logging
for(java.util.logging.Handler item : Logger.getLogger("").getHandlers()) {
item.setLevel(java.util.logging.Level.ALL);
}
Logger.getLogger("").setLevel(java.util.logging.Level.FINE);
//suppress apache logs
java.util.logging.Logger.getLogger("org.apache.http.wire").setLevel(java.util.logging.Level.OFF);
//CloseableHttpClient httpclient = HttpClients.createDefault();
(new WebClient()).getPage("https://publicobject.com/helloworld.txt");
System.out.println("org.apache.http.wire=" + java.util.logging.Logger.getLogger("org.apache.http.wire").getLevel());
這將返回:
org.apache.http.wire=null
如果我使用Apache HttpClient的直接或參考的Apache的HttpClient的HtmlUnit(即取消對CloseableHttpClient線)之前,則日誌記錄被抑制,並且輸出回報:
org.apache.http.wire=OFF
任何有關如何抑制「或g.apache.http.wire「日誌沒有我的hack在HtmlUnit之前引用CloseableHttpClient?