<logger
level="ERROR"
doc:name="Logger"
doc:id="45653f08"
message="my logger message"
category="My OPTIONAL CUSTOM CATEGORY"/>
Logger Component (<logger/>)
Configure messages for logs anywhere in a Mule flow. Mule applications print the messages when the Logger executes.
Component XML
This component supports the following XML structure:
Logger (<logger/>
) attributes are configurable through the UI and XML.
Attribute Name | Attribute XML | Description |
---|---|---|
Logger (default) |
|
Editable name for the component to display in the canvas. |
N/A |
|
Automatically generated identifier for the component. |
Message |
|
A string in double or single quotation marks, a DataWeave expression, a Mule variable, or a concatenated combination of supported values that serve as the message. When this field is empty, the Logger produces the following message:
|
Level |
|
Options are |
Category |
|
Optional string that describes the logger in a way that helps you distinguish it from other loggers in your flow. In the console, the logger replaces the generic processor name with your category. |
Examples
The following example sets a string as the message:
<logger
level="INFO"
doc:name="Logger"
doc:id="45653f08"
message="hello world"/>
When the application with this configuration runs, an entry like this one prints to the console:
INFO 2023-06-09 23:18:03,390 [[MuleRuntime].uber.24: [my-app-1.0.0-SNAPSHOT-mule-application].my-appFlow.BLOCKING @55f71e0b] [processor: my-appFlow/processors/3; event: 8e0db930-0756-11ee-8aae-147ddaaf4f97] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: hello world
The following example sets a category and uses DataWeave to concatenate a field in the message payload to the a string. Notice the #[]
indicates that the message contains an expression or variable.
<logger
level="INFO"
doc:name="Logger"
doc:id="45653f08"
message="#[payload.id ++ " is the ID of this payload."]"
category="PAYLOAD ID"/>
If you assume that the payload is {"id" : 12345, "message" : "hello!"}
, an entry like this one prints to the console:
INFO 2023-06-09 23:18:03,390 [[MuleRuntime].uber.24: [my-app-1.0.0-SNAPSHOT-mule-application].my-appFlow.BLOCKING @55f71e0b] [processor: my-appFlow/processors/3; event: 8e0db930-0756-11ee-8aae-147ddaaf4f97] MY PAYLOAD: 12345 is the ID of this payload.