Contact Us 1-800-596-4880

Logger Component Reference

Use the Logger to log messages such as error messages, status notifications, or exceptions. You can add a logger anywhere in a flow, and you can configure it to log anything: any string, any Mule expression, or any combination of strings and Mule expressions.

Configuration

STUDIO Visual Editor

Field Value Description Example XML

Display Name

Logger

Customize to to display a unique name for the logger in your application

doc:name="Logger"

Message

String or Mule expression

Specify what Mule should log. By default, messages are logged to the console in Mule Studio.

message="Current payload is #[message.payload]"

Level

Select a level from listed options:

  • ERROR

  • WARN

  • INFO

  • DEBUG

  • TRACE

Specify the level at which the message should be logged.

By default, Mule Studio will not log messages at the DEBUG or TRACE level to the console unless you create and configure a log4j.properties file in src/main/resources to lower the log level.

level="INFO"

Category

Optional

String

Optionally specify a category name and configure it in the log4j.properties file to behave per your use case. For example, you can route log messages based on category or set log levels based on category.

category="MyCustomCategory"

XML Editor or Standalone

# A logger set to monitor message processing status
<logger category="monitoring" message="Message #[payload.id] processed successfully" level="INFO" doc:name="Monitoring Logger"/>

# A logger set to record the processing time of a flow
<logger category="performance" message="Message #[payload.id] took #[flowVars['processingTime']] milliseconds to process" level="INFO" doc:name="Performance Logger"/>
Element Description

Logger

Use the Logger to log messages such as error messages, status notifications, or exceptions to the application’s log file.

Element Attribute Description

Message

Specify what Mule should log. Supports expressions.

Level

Select one of the following levels:

  • ERROR

  • WARN

  • INFO

  • DEBUG

  • TRACE

If no level attribute is set, the logger will log at the DEBUG level.

Category

Optional. Specify what categories to route log entries according to business needs. Configure the categories in your log4j.properties file

doc:name

Customize to display a unique name for the logger in your application.

Note: Attribute not required in Mule Standalone configuration.

Rather than specifying a single Mule expression in your logger message, you can embed as many expression as required for you use case. This allows you to give some context to what is being logged, and enables you to log multiple things at once.

<logger message="Current payload is #[message.payload] and message id is #[message.id]" level="INFO" doc:name="Logger"/>

Configuring the log4j.properties File

By default, the logger is set to log messages at a level greater or equal to INFO, and thus will discard log messages at the DEBUG or TRACE level.

If you need to adjust the logging level or define custom categories, you can configure your log4j.properties file to define how the logger behaves. In Mule Standalone, your log4j.properties file is in your $MULE_HOME/conf folder. In Mule Studio, you need to create the log4j.properties file under src/main/resources. A sample file is provided below.

Example log4j.properties File
# Default log level
log4j.rootCategory=INFO, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%-5p %d [%t] %c: %m%n
################################################
# You can set custom log levels per-package here
################################################
# CXF is used heavily by Mule for web services
log4j.logger.org.apache.cxf=WARN
# Apache Commons tend to make a lot of noise which can clutter the log.
log4j.logger.org.apache=WARN
# Reduce startup noise
log4j.logger.org.springframework.beans.factory=WARN
# Mule classes
log4j.logger.org.mule=INFO
log4j.logger.com.mulesoft=INFO
# Reduce DM verbosity
log4j.logger.org.jetel=WARN
log4j.logger.Tracking=WARN

See Also