Contact Free trial Login

log

log(String, T): T

Logs the specified value with an optional prefix, then returns the value unchanged. The function logs the output as a system log.

This function can be used to debug DataWeave scripts until a proper debugger is incorporated.

Parameters

Name Description

prefix

A string that typically describes the log.

value

The value to log.

Example

This example produces the output shown below in a Logger (through the Mule LoggerMessageProcessor), while the Mule DefaultLoggingService prints My Age - 33 in the console output.

Source

%dw 2.0
output application/xml
var myvar = { "age" : 33 }
---
{ "age": log("My Age", myvar.age) }

Output

<?xml version="1.0" encoding="UTF-8"?>
<age>33</age>