Mule applications produce a (sometimes) lengthy log output that is displayed on the console and saved to the Mule log file. This can be tweaked to show more, or less, output but you may sometimes need to see all the log entries (or need to not see them).
Mule uses Log4j for its logging purposes. All logging features are configured using the standard log4j.properties text file that should be placed in the same directory as your Mule application. There is a log4j.properties file under MULE_HOMEconf.
The first line in this file allows you control what level of logs you wish to see, for example:
This line specifies that informational messages should be displayed on the console. Actually, informational messages and any messages considered to be of a higher category are listed. The categories are as follows:
1 – FATAL refers to critical events that will lead to Mule terminating completely.
2 – ERROR refers to any sort of exception, even non-FATAL ones.
3 – WARN refers to warnings; not exceptions but situations that could be harmful.
4 – INFO refers to information that shows how Mule operates and its ongoing progress. It is a rather rough look at the application’s progress but helps you see what’s going on.
5 – DEBUG is the most detailed level of logging and shows all events that have occurred. This is the most useful manner in which to debug the sequence of events in an application.
Given this list, you can set your logging category to INFO which will include anything that would have been caught by the WARN, ERROR and FATAL categories.
The second parameter shown in the example above is “stdout” and instructs log4j to post all these messages on to the standard output device. You can add “file” to save these items into the Mule log file:
or you can remove “stdout” so that all INFO messages will be placed in the file but not shown on screen:
Logs are displayed on screen (or saved into a file) based upon the behaviour encoded in log4j appender classes. The next two sections in a log4j.properties file define these classes and their properties. This example shows how log4j is being configured to store logs in a file called mule.log that should have a maximum size of 10MB:
log4j.appender.file=org.apache.log4j.RollingFileAppender log4j.appender.file.File=mule.log log4j.appender.file.MaxFileSize=10MB
The class used is called org.apache.log4j.RollingFileAppender which backs up log files once they reach a certain size.
Rather usefully, you can also configure log4j to use specific log categories for particular classes but not for the whole Mule application:
This example shows how only FATAL log messages should be displayed on screen; but any DEBUG messages generated by any class in the org.mule.model.* package (or packages) will also be displayed. It is a great mechanism to display detailed messages for the classes that are causing problems while debugging for instance.