3. Setting up logging

If you're running XML Calabash on the command line, or through a shell script or batch file, it's possible to get it to print a lot of additional information as it runs. If you're running in an embedded environment like an editor, it's less clear to me how (or if) logging messages are available, but it's possible.

To start off with, let me come clean, the Java logging ecosystem is messy. There are a bunch of different API standards and a bunch of different implementations and a bunch of bunches of other bunches of things. As far as I can tell.

I believe that I've configured XML Calabash in such a way that those familiar with the dark arts of Java logging can swap out my logging implementation for one of their own choosing. If I'm wrong, I'd be happy if you tell me. I don't know, I can't tell, and I'm not even going to try to explain it. I think it's just a matter of swapping some implementation jar files. Maybe.

I ship XML Calabash with the SLF4J facade and the Apache Log4j 2 implementation.

What this means to you is that you can change the logging messages by putting a Log4j configuration file on the classpath before xmlcalabash-1.1.13.jar.

Here's the one that I use:

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn">
    <Console name="Console" target="SYSTEM_ERR">
      <PatternLayout pattern="%-5level: %msg%n" />
    <Logger name="com.xmlcalabash" level="debug" additivity="false">
      <AppenderRef ref="Console"/>
    <Root level="warn">
      <AppenderRef ref="Console" />

In order to keep the logger happy if you don't have a logger configuration file on your classpath, XML Calabash ships with a default one that only logs “info” messages.