In line with most server type applications, Node-RED outputs all sorts of operational and error information to a log. In addition to Node-RED’s own logging, each node that you use may also add to the log.
You can also output your own information to the log from your flows, those methods are shown at the end of this article.
There are three categories of ways to actually run Node-RED and each will require you to access the log in a slightly different way.
Running Node-RED as a “Service” 🔗︎
If you install Node-RED using the script supplied for installation on a Raspberry Pi (or any other Debian-like host), Node-RED will be run as a system service. That is to say that it will be started up when the system boots. You can also do this on other platforms including Windows.
In these cases, typically system log output goes to a standard service such as
syslog. Typically, the syslog output is found in a file at
/var/log/syslog and you can use the
tail command from a terminal command prompt to view it.
On most modern versions of Linux though, the syslog is being overtaken by logging built into the
systemd service. In these cases, it is better to use the
journalctl command to show the log output. This has the advantage that you only need to know the service name (
node-red on a standard Pi install) and you don’t need to worry about where the actual data is stored. You can also use the more advanced features of that command to output logs in different formats.
The following command will show you the last 50 lines of the log, jumps to the last output and “follows” any further output.
journalctl -u node-red -e -f -n 50
Windows does not use log output in the same way that Linux does as it has the “Event Logs”. Typically, log output is redirected to a file and you will need to look at the startup command for Node-RED to see where the logs are being written to.
Running Node-RED manually 🔗︎
On all platforms, if you run Node-RED manually from the command line, the log output is shown in the same terminal. Using the keyboard command ctrl-c will both stop Node-RED and close the log.
Using a “runner” to run Node-RED 🔗︎
Sometimes, especially during development, it is helpful to use a “runner” application such as
nodemon to start Node-RED. These will recover from failures and can be made to “watch” for changes to files and restart automatically.
Each of these tools may have their own ways of viewing log output. For example, when using the popular pm2 runnner, the command is
Changing log output levels 🔗︎
By default, Node-RED will show the following types of output from both Node-RED and any installed nodes:
fatal- only those errors which make the application unusable should be recorded
error- record errors which are deemed fatal for a particular request + fatal errors
warn- record problems which are non fatal + errors + fatal errors
info- record information about the general running of the application + warn + error + fatal errors
You can change the logging levels to also show:
debug- record information which is more verbose than info + info + warn + error + fatal errors
trace- record very detailed logging + debug + info + warn + error + fatal errors
Or you can remove levels or turn off logging alltogether (using the
In addition, there are 2 other settings that impact logs:
metrics- Whether or not to include metric events in the log output
audit- Whether or not to include audit events in the log output
All of these settings are found (complete with instructions) in the
settings.js file typically found in the
userDir folder (normally
Outputting your own information to the log 🔗︎
When writing flows in Node-RED, you will normally use the
debug node that, by default, outputs to the debug sidebar in the Node-RED Editor (admin UI). However, you can change the settings in the debug node to also (or instead) output to the log.
In addition, you can also output to the log from a
function node using the code:
node.warn('some useful text')
Mar 17 17:12:48 pi node-red: 17 Mar 17:12:48 - [warn] [function:My useful fn node] some useful text
If you give your function node a reasonably name, you will see that in the output as shown. If the node doesn’t have a name, the id will be shown, you can use that in the Editor’s search feature to find the node.