This page last changed on Apr 08, 2006 by aperepel.

The following describes how Logging is configured in Mule and how you can change it.
Mule uses commons-logging which is a logging facade that 'discovers' a logging strategy on the classpath such as Log4J or the JDK Logger and uses that for logging. By default, Mule ships with Log4J which is configured with a file called log4j.properties.
 

The Mule server itself does not ship with a log4j.properties this is because many applications already have Log4J configuration, so throwing another log4j.properties in the mix would confuse things. However, the samples that ship with Mule all have a log4j.properties file for configuring logging. These can be used by your application if you do not already have a logging configuration.

Troubleshooting

I Don't see any logging output?

You need to have a log4j.properties file at the root of your classpath. If you don't have a log4j.properties you can get a simple one here. For more information about configuring Log4J, see their website.

I reconfigured Log4J but nothing happened

This happens because there is another log4j.properties file on your classpath that is getting picked up before your modified one. To find out which configuration Log4J is using you need to add the following JVM parameter to the Mule start up script (or container start up script if you are embedding Mule) -

-Dlog4j.debug=true

This will write the Log4J start up information to stdout that includes the location of the configuration being used. You'll need to remove this configuration before your modified configuration will work.

I don't want to use Log4J

You just need to remove the log4j-xx.jar from your Mule classpath. You will then need to check that the logging system you are using is supported by commons-logging and put the necessary jar (unless using JDK1.4 Logger) and configuration files on the Mule classpath. At time of writing commons logging supports Log4J versions 1.2x and 1.3x, JDK1.4 Logger, Avalon Logkit, JDK1.3 Lumberjack Logger and an internal SimpleLogger implementation.

Controlling Logging from JMX

You can expose a managers logging configuration over JMX by configuring a Log4J Jmx agent in your Mule Xml -

<agents>
    <agent name="Log4jJmx" className="org.mule.management.agents.Log4jAgent"/>
</agents>

Default JMX Support Agent

You can configure all Jmx Agents with a single class called DefaultJmxSupportAgent. It will register your Mule instance with the following agents -

  • Rmi agent (if necessary) on rmi://localhost:1099
  • Jmx Registration agent
  • Remote Jmx access on service:jmx:rmi:///jndi/rmi://localhost:1099/server
  • Jmx Notification agent used to receive Server notifications using Jmx Notifications
  • Log4J Jmx Agent
  • (Optional) JDMK Agent - set loadJdmkAgent property to true (@since Mule 1.3.1)
  • (Optional) MX4J Agent - set loadMx4jAgent property to true (@since Mule 1.3.1)

Just add the following to your configuration -

<agent name="JMX" className="org.mule.management.agents.DefaultJmxSupportAgent"/>

The agent does a lot of useful plumbing for JMX, however at the expense of defaulting many parameters. If you find a need to customize some subsystems you could either:

  1. Subclass DefaultJmxSupportAgent and override corresponding createXXX() factory methods.
  2. Disassemble the services provided by this support agent into separate agents and configure them individually.
Document generated by Confluence on Nov 27, 2006 10:27