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.
Configuration
Section titled “Configuration”- Script language — required. Choose
TBELorJavaScript. - 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.
Message processing algorithm
Section titled “Message processing algorithm”- Execute the user-defined script, passing
msg,metadata, andmsgType. - Write the returned string to
thingsboard.logat INFO level. - Forward the original message (unchanged) via
Success. - If the script throws an exception, route via
Failure.
Output connections
Section titled “Output connections”| Connection | Condition |
|---|---|
Success | Script executed successfully; original message forwarded unchanged. |
Failure | Script execution failed (syntax error, runtime exception). |
Examples
Section titled “Examples”Example 1 — Basic telemetry log
Section titled “Example 1 — Basic telemetry log”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.
JSON schema
Section titled “JSON schema”{ "$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." } }}