My tech blog

Turning off HtmlUnit driver logging messages

leave a comment »

HtmlUnit was throwing lots of log messages while using cuke4duke (cucumber) to test our website from maven and I wanted to turn them off temporary but I struggled a bit. This is the solution I found on Stack Overflow:

I created the file under /src/main/resources and I specify that my logging framework is log4j (commons is just a wrapper):

# JDK Logging
# Log4j logging (also required log4j.jar to be in classpath)

I created the log4j.xml file in the same folder /src/main/resources:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j="">

    <appender name="out" class="org.apache.log4j.ConsoleAppender">
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{yyyy-MM-dd, HH:mm:ss} %p - %m%n" />

        <priority value="error" />
        <appender-ref ref="out" />

and I added the missing dependency to log4j in the pom.xml file:



Written by alexcuesta

May 11, 2011 at 4:56 pm

Posted in Java, Testing

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: