---
schema_version: "1"
id: 039fb7ff66cac868f484b9d4a0d67de2e9961e7b156ea052430c825f91e7cafa
title: log
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.3/dw-core-functions-log.md
canonical_url: https://docs.mulesoft.com/dataweave/2.3/dw-core-functions-log
source_site: docs.mulesoft.com
content_type: documentation
content_hash: e624ca304065ebc2b9ac9aeab3c99574ebe3aff6cf199555b21f7c93fefd8d1c
description: MuleSoft Documentation Site
release: "2.3"
latest: false
---
---
product: DataWeave
version: 2.3
---

# log

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

## log(String, T): T

Without changing the value of the input, `log` returns the input as a system log.

Use this function to help with debugging DataWeave scripts. A Mule app outputs the results through
the `DefaultLoggingService`, which you can see in the Studio console.

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>prefix</code></p></td><td><p>An optional string that typically describes the log.</p></td></tr><tr><td><p><code>value</code></p></td><td><p>The value to log.</p></td></tr></tbody></table>

### Example

This example logs the specified message. Note that the `DefaultLoggingService` in a Mule app that is
running in Studio returns the message `WARNING - "Houston, we have a problem,"` adding the dash `-`
between the prefix and value. The Logger component’s `LoggerMessageProcessor` returns the input
string `"Houston, we have a problem."`, without the `WARNING` prefix.

#### Source

```DataWeave
%dw 2.0
output application/json
---
log("WARNING", "Houston, we have a problem.")
```

#### Console Output

```XML
WARNING - "Houston, we have a problem."
```

#### Expression Output

```XML
"Houston, we have a problem."
```

### Example

This example shows how to log the result of expression `myUser.user` without modifying the original
expression `myUser.user.friend.name`.

#### Source

```DataWeave
%dw 2.0
output application/json

var myUser = {user: {friend: {name: "Shoki"}, id: 1, name: "Tomo"}, accountId: "leansh" }
---
log("User", myUser.user).friend.name
```

#### Console Output

```linenums
 User - {
   friend: {
     name: "Shoki"
   },
   id: 1,
   name: "Tomo"
 }
```

#### Expression Output

```linenums
"Shoki"
```
