Ova

How to see console log in Node-RED?

Published in Node-RED Logging 5 mins read

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:
    1. Open your Node-RED editor (usually at http://localhost:1880).
    2. Click the bug icon (๐Ÿ›) on the right-hand sidebar. This will open the Debug tab.
  • 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.

Example:
To see the content of a message at a specific point in your flow:

  1. Drag a debug node from the palette onto your flow.
  2. Connect its input to the output of the node you want to inspect.
  3. Ensure the debug node is configured to output msg.payload (or complete msg object for full detail).
  4. Deploy your flow.
  5. 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:
    1. Within your Node-RED environment, look for an option to select Node-RED Console Log.
    2. This action will typically open a Log Viewer page, displaying the log content.
    3. From the Log Viewer page, you can choose to View the information in a separate web page for more detailed inspection.
    4. 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:
    1. If you started Node-RED manually: The logs will appear directly in the terminal window where you executed the node-red command.
    2. If running as a service (e.g., systemd, PM2):
      • For systemd (Linux): Use journalctl -u nodered -f (replace nodered with your service name) to follow logs in real-time.
      • For PM2: Use pm2 logs node-red (replace node-red with your PM2 app name).
    3. For Docker containers: Use docker logs -f <container_name_or_id>.

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 in settings.js.
  • Configuration:
    1. Locate your settings.js file (usually in ~/.node-red).
    2. Find the logging section. You can configure various appenders here, including a file appender.
    3. Adjust log levels (fatal, error, warn, info, debug, trace) for different categories to control verbosity.

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.