Monday, June 30, 2014

How to Disable Selenium HtmlUnitDriver logging

Recently, while working on a project using Selenium HtmlUnitDriver, i found that it generates too much log messages by default to output console which really fills the screen with non wanted messages.


So, like me some of you may also get this and wanted to resolve the same. What i did is added the below code statements to suppress the logging messages.


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

and it Worked :) :)

3 comments:

Lalit Narnaulia said...

[img]http://s20.postimg.org/gfz8soewd/how_to_disable_selenium_htmlunitdriver.png[/img]

Jay said...

This worked perfect for me too! Although I had to alter my log4j.properties file to the following to make it work properly. Thank you!!!

# Root logger option
log4j.rootLogger=WARN, file

Lalit Narnaulia said...

Hey Thanks John, for adding your solution

AWS Certified Solutions Architect Associate - AWS Introduction - Questions

All the Best !!! Show Result !! Try Again !! ×