---
schema_version: "1"
id: 530cf47a15e55d99ad599a0aec12b90bff5654848680aca96039a802ce725c20
title: log
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.8/dw-core-functions-log.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.8/dw-core-functions-log
source_site: docs.mulesoft.com
content_type: documentation
content_hash: d52566892034ed7f4b5925aa57ffdd77440ce5477d8bad2b7210168f22cafd55
description: MuleSoft Documentation Site
release: "2.8"
latest: false
---
# log

## [](#log1)log<T>(prefix: String = "", value: T): T

入力の値を変更することなく、​`log`​ は入力をシステムログとして返します。そのため、任意の式またはサブ式を ​**log**​ でラップでき、式の結果を変更することなく結果が出力されることから、コードのデバッグが非常に単純になります。 The output is going to be printed in application/dw format.

The prefix parameter is optional and allows to easily find the log output.

この関数を使用して、DataWeave スクリプトのデバッグを容易にします。Mule アプリケーションは ​`DefaultLoggingService`​ を介して結果を出力し、結果は Studio コンソールで参照できます。

### [](#パラメーター)パラメーター

<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 75%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">名前</th>
<th class="tableblock halign-left valign-top">説明</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>prefix</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">通常はログを説明する文字列 (省略可能)。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>value</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">ログに記録する値。</p></td>
</tr>
</tbody>
</table>

### [](#例)例

次の例では、指定されたメッセージをログに記録します。Studio で実行されている Mule アプリケーションの ​`DefaultLoggingService`​ は、プレフィックスと値の間にダッシュ ​`-`​ を追加したメッセージ ​`WARNING - "Houston, we have a problem,"`​ を返します。Logger コンポーネントの ​`LoggerMessageProcessor`​ は、​`WARNING`​ プレフィックスのない入力文字列 ​`"Houston, we have a problem."`​ を返します。

#### [](#ソース)ソース

```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"
```

### [](#例-2)例

この例は、元の式 ​`myUser.user.friend.name`​ を変更せずに式 ​`myUser.user`​ の結果をログに記録する方法を示しています。

#### [](#ソース-2)ソース

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

#### [](#出力-2)出力

`Console output`

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

`Expression Output`

```DataWeave
"Shoki"
```