Changing the Logging in ServiceMix

ServiceMix uses Log4j by way of Apache Commons Logging for logging purposes. Via the Log4J configuration, the logging can be almost completely customized to suit your needs. Below are a couple of common changes people need right away. For any additional changes and for more information on Log4J, see the Log4J manual.

Step One: Change the Root Logger Level

Edit the conf/log4j.xml file and change the root level on or around line #66 from this:

<root>
  <level value="INFO"/>
  ...
</root>

to this:

<root>
  <level value="DEBUG"/>
  ...
</root>

Step Two: Change an Appender

There are two appenders provided by default in the conf/log4j.xml file - one named CONSOLE and another named FILE. The CONSOLE appender has its threshold set to INFO by default. If you'd like the logging output to the console to be the debug level logging, change the CONSOLE appender from this:

 
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
  <param name="threshold" value="INFO"/>
  <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern" value="%-5p - %-30c{1} - %m%n"/>
  </layout>
</appender>

to this:

 
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
  <param name="threshold" value="DEBUG"/>
  <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern" value="%-5p - %-30c{1} - %m%n"/>
  </layout>
</appender>

Notice that the only element that was changed was the threshold parameter. This change allows the logging output to the console to be at the debug level.

Changing Logging For Projects Included in ServiceMix

There are times when you need to change the logging for a another project that is included in ServiceMix such as ActiveMQ, Camel, Spring, etc.

  1. Follow the two steps in the previous section to change the root level logger and an appender
  2. Change an existing logger or add your own logger for the package from which you want to see the debug logging

For example, let's use ActiveMQ as one example. To output debug level logging from ActiveMQ as it's deployed inside of the ServiceMix container, change the following logger from this:

<logger name="org.apache.activemq">
  <level value="WARN"/>
</logger>

To this:

<logger name="org.apache.activemq">
  <level value="debug"/>
</logger>

After making this change, ServiceMix will output debug level logging for ActiveMQ.

ServiceMix inside OpenESB / Glassfish

If ServiceMix is deployed inside Glassfish (through OpenESB) then logging will not work because Glassfish only supports the JDK Logging out of the box. You can find help on the Glassfish FAQ. This of course will write the logging to a separate file but at least the logging statements are not silently swallowed anymore.