How to disable detailed reports on htmlunit?

htmlunit reports everything from css, parses errors on the page.

how to silence this?

+3
source share
3 answers

HTMLUnit uses Apache community logging, which delegates the actual logging to the "real" logging structure or standard java version.

If your application uses log4j, you can use it to reduce the chtiness of htmlunit.

More information can be found on the documentation page.

+1
source

Put them after the webClient declaration

            webClient.setCssErrorHandler(new SilentCssErrorHandler());
            LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog");
            java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit").setLevel(Level.OFF);
            java.util.logging.Logger.getLogger("org.apache.commons.httpclient").setLevel(Level.OFF);
            java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter").setLevel(Level.OFF);
            java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit.javascript.host.ActiveXObject").setLevel(Level.OFF);
            java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit.javascript.host.html.HTMLDocument").setLevel(Level.OFF);
            java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit.html.HtmlScript").setLevel(Level.OFF);
            java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit.javascript.host.WindowProxy").setLevel(Level.OFF);
            java.util.logging.Logger.getLogger("org.apache").setLevel(Level.OFF);
+6
source

HTMLUnit JAVA.

, .

java.util.logging.Logger.getLogger("com.gargoylesoftware").setLevel(Level.OFF);
0

Source: https://habr.com/ru/post/1749849/


All Articles