Fuse ESB uses the OPS4j Pax Logging system, a standard OSGi logging service that also supports the following APIs:
Apache Log4j
Apache Commons Logging
SLF4J
Java Util Logging
Three
configuration files in the
directory are used in configuring Fuse ESB logging:InstallDir
/etc
-
org.ops4j.pax.logging.cfg
Uses standard Log4j configuration to set the root logger's level to
INFO
and to define two appenders: one for the console and one for the log file. The console's appender is disabled by default. To enable it, addlog4j.appender.stdout.append=true
to the.cfg
file.-
org.apache.karaf.log.cfg
Configures the output of the log console commands.
-
system.properties
Contains one property,
org.ops4j.pax.logging.DefaultServiceLog.level
, which sets the logging level early in the boot process when the pax-logging service it not yet available. This is set to ERROR by default.
The default logging configuration sets the logging levels so that the log file will provide enough information to monitor the behavior of the runtime and provide clues about what caused a problem. However, the default configuration will not provide enough information to debug most problems.
The most useful logger to change when trying to debug an issue with Fuse ESB is the root
logger. You will want to set its logging level to DEBUG
in the
org.ops4j.pax.logging.cfg
file.
Example 4.1. Changing Logging Levels
# Root logger log4j.rootLogger=DEBUG, out, osgi:VmLogAppender ...
When debugging a problem in Fuse ESB you may want to change the level of logging
information that is displayed on the console. Example 4.2 shows an example of setting the root logger to DEBUG
but limiting the
information displayed on the console to WARN
.
Example 4.2. Changing the Log Information Displayed on the Console
log4j.rootLogger=DEBUG, stdout, osgi:VmLogAppender
...
log4j.appender.stdout.threshold=WARN
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %-32.32C %4L | %m%n
...
It is possible to reconfigure Fuse ESB logging so that it writes one log file for each
bundle, instead of writing all of the log messages into a single log file. This feature is
enabled by adding the Log4j sift
appender to the Log4j root logger. Open the
etc/org.ops4j.pax.logging.cfg
file using a text editor and add
sift
to the root logger, as follows:
# Root logger
log4j.rootLogger=INFO, out, sift, osgi:VmLogAppender
After restarting the container, you can see that each
BundleName
bundle now has its own log file, located at:
data/log/BundleName
.log
This is the behavior you will see with the default sift appender settings (see the sift
appender configuration settings in org.ops4j.pax.logging.cfg
).
For more information on Pax logging, see http://wiki.ops4j.org/display/paxlogging/Pax+Logging.