HtmlUnit uses the commons logging package from the Apache Jakarta project. Commons logging is a thin wrapper that sits on top of other logging frameworks such as LOG4J or LogKit.

For full details on configuring commons logging, refer to the homepage.

If you don't explicitly configure commons logging to use LOG4J or another logging framework then it will use the simple logger. When using the simple logger, you can change the default logging level by setting the following system property.

System.getProperties().put("org.apache.commons.logging.simplelog.defaultlog", "trace");

Valid values for this property are "trace", "debug", "info", "warn", "error", or "fatal" (in order from least serious to most serious).

Noteworthy loggers

In HtmlUnit, each class has its own log named according to the class's fully qualified name.

HtmlUnit uses Apache HttpClient which uses "org.apache.http" to log the headers and wire content, please read more in HttpClient Logging Practices

Logging HTML parsing messages

The package used to parse the HTML has the ability to report the problems it encounters while parsing source. These messages may be programmatically catched or easily logged to the "com.gargoylesoftware.htmlunit.html.HTMLParserListener" log for instance by calling:

final WebClient webClient = new WebClient();
The parser (NekoHTML) by default processes the content that is outside of the BODY and HTML tags. This is seen by the logging reporting that the BODY and HTML tags are not closed properly. This can be changed by calling 'WebClient.setIgnoreOutsideContent(true);'.