Dashboard > Selenium Remote Control > ... > Selenium RC Logging > Selenium RC Logging for Developers
Selenium Remote Control Log In View a printable version of the current page.
Selenium RC Logging for Developers
Added by Dan Fabulich, last edited by Dan Fabulich on Jul 15, 2007  (view change)
Labels: 
(None)

Internally, Selenium Server uses Jetty's org.mortbay.log.LogFactory. (That way, Jetty logs and Selenium Server logs are automatically directed to the same location.) Jetty's LogFactory is a thin wrapper around Jakarta Commons-Logging (JCL), which, by default, uses java.util.logging, aka JDK logging.

The SeleniumServer class configures the JDK logger to print INFO messages to stdout, and to print WARN & ERROR messages to stderr. If -debug is set, we print DEBUG messages to stdout also; if -log is set, we configure the JDK logger to print to a file. Message printed to the console don't contain as much information as the log file.

Feel free to reconfigure the JDK logger yourself, by specifying a java.util.logging configuration file, if you have one.

java -Djava.util.logging.config.file=my-logging-configuration.properties -jar selenium-server.jar

Using Chainsaw with our logs

Our logs can be parsed/grepped fairly easily, but you may prefer using a GUI-based log manager like Chainsaw to manage the logs.

Just download the "Unix/Dos standalone" version from the Chainsaw website, and configure Chainsaw using the LogFilePatternReceiver.

Here's an example Chainsaw configuration file:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration PUBLIC "-//log4j/log4j Configuration//EN" "log4j.dtd"> 
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true">

   <plugin name="logFileReceiver" class="org.apache.log4j.varia.LogFilePatternReceiver">
     <param name="fileURL" value="file:///c:/my/path/to/selenium.log" />
     <param name="timestampFormat" value="HH:mm:ss"/> 
     <param name="logFormat" value="TIMESTAMP LEVEL [THREAD] LOGGER - MESSAGE"/> 
     <param name="name" value="Selenium Log" />
     <param name="tailing" value="true" /> 
   </plugin>

   <root>
      <level value="debug"/>
   </root>
</log4j:configuration>

Note that you'll need to change the "fileURL" parameter to the correct path to your Selenium log file. Also note that we set "tailing" to true; that means that Chainsaw will automatically add more logging messages as the selenium.log file grows. If you need to modify the receiver configuration (i.e. change the patth to the log file) while Chainsaw is running, don't forget to clear out the log window and restart the "Selenium Log" receiver. You'll also need to restart the receiver if you clear out the log file (e.g. if you restart the Selenium Server and it deletes the old log file, replacing it with a new one).

Using a different logger

You can easily configure JCL to use a different logger, e.g. log4j. It's easy to hook log4j up to log4net, log4php, log4perl, log4py, or log4r.

Just add log4j to the classpath, and Commons-Logging will automatically start using that. (Some people believe that the commons-logging behavior is a bad idea; they might be right.) If you do that, don't forget to configure log4j with a configuration properties file.

java -Dlog4j.configuration=log4j.properties -cp log4j-1.2.14.jar;selenium-server.jar org.openqa.selenium.server.SeleniumServer

If you're having trouble getting log4j to work, you may want to consult the JCL documentation.

Site running on a free Atlassian Confluence Community License granted to OpenQA. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.6 Build:#812 Aug 06, 2007) - Bug/feature request - Contact Administrators