---
schema_version: "1"
id: e1bc9e66ad172fcd14c174497eb4ebeb6ad5a77b756370c3d9b7c25ca2e65c96
title: Logger Component (<logger/>)
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/anypoint-code-builder/acb-component-logger.md
canonical_url: https://docs.mulesoft.com/anypoint-code-builder/acb-component-logger
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 1c2dc69584bf7130600135f34ba9dfbfa07cde15d5aa3218ce6229df26387617
description: MuleSoft Documentation Site
latest: true
---
---
product: Anypoint Code Builder
version: master
---

# Logger Component (<logger/>)

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

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:

```xml
<logger
  level="ERROR"
  doc:name="Logger"
  doc:id="45653f08"
  message="my logger message"
  category="My OPTIONAL CUSTOM CATEGORY"/>
```

Logger (`<logger/>`) attributes are configurable through the UI and XML.

<table><colgroup><col> <col> <col></colgroup><thead><tr><th>Attribute Name</th><th>Attribute XML</th><th>Description</th></tr></thead><tbody><tr><td><p><strong>Logger</strong> (default)</p></td><td><p><code>doc:name</code></p></td><td><div><div><p>Editable name for the component to display in the canvas.</p></div></div></td></tr><tr><td><p>N/A</p></td><td><p><code>doc:id</code></p></td><td><div><div><p>Automatically generated identifier for the component.</p></div></div></td></tr><tr><td><p><strong>Message</strong></p></td><td><p><code>message</code></p></td><td><div><div><p>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:</p></div><div><div><pre><code data-lang="json">{
  payload=&lt;not set&gt;
  mediaType=*/*
  attributes=&lt;not set&gt;
  attributesMediaType=*/*
}</code></pre></div></div></div></td></tr><tr><td><p><strong>Level</strong></p></td><td><p><code>level</code></p></td><td><div><div><p>Options are <code>DEBUG</code>, <code>ERROR</code>, <code>INFO</code> (default), <code>TRACE</code>, <code>WARN</code>. In the console, the logger message begins with the <code>level</code>.</p></div></div></td></tr><tr><td><p><strong>Category</strong></p></td><td><p><code>category</code></p></td><td><div><div><p>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.</p></div></div></td></tr></tbody></table>

## Examples

The following example sets a string as the message:

```xml
<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.

```xml
<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.

## See Also

- [Predefined Mule Variables](https://docs.mulesoft.com/dataweave/2.4/dataweave-variables-context)

- [DataWeave Reference](https://docs.mulesoft.com/dataweave/2.4/dw-functions)

- [DataWeave Tutorial and Playground](https://dataweave.mulesoft.com)
