How to display logs when setting Node-RED as a scheduled task on Windows

I run Node-RED on Windows 10 startup by setting it as a scheduled task, according to the documentation " Run Node-RED on Startup".
Is there a way to display the log to the CLI, like PowerShell, with some command like node-red-log, which is used when running Node-RED on Raspberry Pi?

As usual, you have a number of choices. The easiest to ensure that the scheduled job doesn't start until a user is actually logged in. Then create a job that has an action to start node-red in the normal way.

Here I'm starting it somewhat differently as I use npm with a package.json file to start my development environment:

As a user is logged in, you will get a console displayed. Of course, you could create a batch/PowerShell script to run node-red but there is little point.

The issue with this is that the console will immediately disappear if Node-RED stops. Not terribly useful if you are trying to track down issues.

To avoid this, redirect all output (including error output) to a file. Then use a decent file viewer to track the output. There are various tools that will track streamed files - I tend to use Notepad++.

Another alternative that many people use is to globally install "pm2", this is a runner for Node.js. Set your job to run Node-RED via pm2. pm2 has log redirection built in. It can be a bit heavy on the resources though if your machine is thin on memory or processor.

Either way of running with log redirection will also let you run Node-RED before a user is logged in if you wish. Though watch out for permissions issues.

I use redirection to log node-red to file
E.g. node-red > log.log however this locks the file so log rotation locks the file.

1 Like