Node-RED provides multiple methods to view console logs, catering to both flow-specific debugging and underlying system diagnostics. The primary ways include the built-in Debug sidebar, dedicated log viewers within certain environments, and direct access to the Node-RED server's terminal or log files.
How to See Console Logs in Node-RED
Understanding how to access Node-RED's console logs is crucial for debugging flows, monitoring performance, and troubleshooting server-side issues. Hereโs a detailed guide on the various methods available.
1. Using the Node-RED Editor's Debug Sidebar
For most flow-related debugging, the Debug sidebar is your go-to tool.
- Purpose: Displays messages sent by
debug
nodes within your flows. - Access:
- Open your Node-RED editor (usually at
http://localhost:1880
). - Click the bug icon (๐) on the right-hand sidebar. This will open the Debug tab.
- Open your Node-RED editor (usually at
- Functionality:
- Messages from
debug
nodes appear here in real-time. - You can filter messages by node, type (e.g., info, warn, error), or clear the output.
- The output can be expanded to inspect the full message payload, including its type and content, which is invaluable for understanding data flow.
- Messages from
Example:
To see the content of a message at a specific point in your flow:
- Drag a
debug
node from the palette onto your flow. - Connect its input to the output of the node you want to inspect.
- Ensure the
debug
node is configured to outputmsg.payload
(orcomplete msg object
for full detail). - Deploy your flow.
- Trigger the flow, and the output will appear in the Debug sidebar.
2. Accessing the Node-RED Console Log Viewer
In certain Node-RED environments or installations, you may have a dedicated UI option for viewing broader system logs.
- Purpose: To view comprehensive system and runtime logs of the Node-RED instance.
- Method:
- Within your Node-RED environment, look for an option to select Node-RED Console Log.
- This action will typically open a Log Viewer page, displaying the log content.
- From the Log Viewer page, you can choose to View the information in a separate web page for more detailed inspection.
- Alternatively, you can Download the log as a text file to save it locally for offline analysis or sharing.
This method provides a centralized way to check Node-RED's operational output, including startup messages, errors from nodes, and configuration details.
3. Checking Server-Side Terminal/Console Logs
Node-RED typically runs as a server application. Its primary console output is usually directed to the terminal or command prompt where it was started.
- Purpose: Essential for monitoring Node-RED startup, underlying system errors, global configuration issues, and verbose logging beyond what the
debug
node provides. - Access:
- If you started Node-RED manually: The logs will appear directly in the terminal window where you executed the
node-red
command. - If running as a service (e.g., systemd, PM2):
- For
systemd
(Linux): Usejournalctl -u nodered -f
(replacenodered
with your service name) to follow logs in real-time. - For
PM2
: Usepm2 logs node-red
(replacenode-red
with your PM2 app name).
- For
- For Docker containers: Use
docker logs -f <container_name_or_id>
.
- If you started Node-RED manually: The logs will appear directly in the terminal window where you executed the
These logs provide insights into:
- Node-RED startup sequence and any initialization errors.
- Errors from nodes that crash the runtime.
- HTTP request details (if configured).
- Messages from external libraries used by custom nodes.
4. Reviewing Node-RED Log Files
For persistent storage and historical analysis of logs, Node-RED can be configured to write its output to files.
- Location: By default, if file logging is enabled, logs are often found in the user's Node-RED directory, typically
~/.node-red/logs
on Linux/macOS or%HOMEPATH%\.node-red\logs
on Windows. The exact path can be configured insettings.js
. - Configuration:
- Locate your
settings.js
file (usually in~/.node-red
). - Find the
logging
section. You can configure various appenders here, including afile
appender. - Adjust log levels (
fatal
,error
,warn
,info
,debug
,trace
) for different categories to control verbosity.
- Locate your
Example logging
configuration in settings.js
:
logging: {
// Console output appender
console: {
level: "info", // Can be set to "debug" for more verbose output
metrics: false,
audit: false
},
// File output appender (uncomment and configure as needed)
file: {
level: "info",
metrics: false,
audit: false,
// Path to the log file - adjust as necessary
path: "/var/log/node-red/node-red.log",
// Max size of the log file before rolling over (e.g., 10MB)
maxNumber: 1,
// Number of backup files to keep
maxFiles: 5
}
},
After modifying settings.js
, restart Node-RED for the changes to take effect. You can then view the log files using standard text editors or command-line tools like tail -f /var/log/node-red/node-red.log
.
Summary of Log Access Methods
Method | Best For | Access Point | Output Type |
---|---|---|---|
Debug Sidebar | Flow-specific msg content |
Node-RED Editor (bug icon) | debug node output (messages, payloads) |
Node-RED Console Log Viewer | General system & runtime logs (UI access) | Specific UI option in certain Node-RED environments | System messages, errors, warnings |
Server Terminal/Console | Startup errors, backend issues, system logs | Terminal where Node-RED started, journalctl , pm2 logs , docker logs |
Raw console output (info, warnings, errors) |
Configured Log Files | Historical data, persistent storage, analysis | File system (e.g., ~/.node-red/logs or custom path) |
Detailed system logs, based on settings.js |
By combining these methods, you can gain a comprehensive understanding of your Node-RED instance's operation and quickly diagnose any issues that may arise.