Skip to content
Stand with Ukraine flag

Log

Use this node to write a custom log entry to the ThingsBoard server log file (thingsboard.log) at the INFO level. It is most useful for debugging rule chains during development — you can inspect message data, metadata, and type in the log without changing message routing. The original message passes through unchanged.

  • Script language — required. Choose TBEL or JavaScript.
  • Script body — required. A function that receives three arguments and must return a string to be written to the log:
    • msg — message data (object or array).
    • metadata — message metadata. In JavaScript, object with string values; in TBEL, java.util.Map<String, String>.
    • msgType — message type as a string.
  1. Execute the user-defined script, passing msg, metadata, and msgType.
  2. Write the returned string to thingsboard.log at INFO level.
  3. Forward the original message (unchanged) via Success.
  4. If the script throws an exception, route via Failure.
ConnectionCondition
SuccessScript executed successfully; original message forwarded unchanged.
FailureScript execution failed (syntax error, runtime exception).

Incoming message

Data: { "temperature": 24.3, "humidity": 58.7 } Metadata: { "deviceName": "Sensor-01", "ts": "1756380600000" } Type: POST_TELEMETRY_REQUEST

Node configuration

{
"scriptLang": "TBEL",
"tbelScript": "return 'Message Type: ' + msgType + ' | Device: ' + metadata.deviceName + ' | Temperature: ' + msg.temperature + '°C | Humidity: ' + msg.humidity + '%';"
}

Log output written to thingsboard.log:

Message Type: POST_TELEMETRY_REQUEST | Device: Sensor-01 | Temperature: 24.3°C | Humidity: 58.7%

The original message is forwarded via Success unchanged.

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "TbLogNodeConfiguration",
"type": "object",
"required": ["scriptLang"],
"additionalProperties": false,
"properties": {
"scriptLang": { "type": "string", "enum": ["JS", "TBEL"] },
"jsScript": { "type": "string", "description": "JavaScript log formatting function body." },
"tbelScript": { "type": "string", "description": "TBEL log formatting function body." }
}
}