as i am trying to learn how to redirect console output to a file, i have discovered lots of responses that are similar to yours: "redirect the console output to a file."
but, i haven't found a good reference that shows how to do that. i found one that suggested it is an edit to my node-red.service, but when i made that change that i thought was recommended, the node-red service would not start.
do you happen to have a reference or code snippet that shows how to redirect the console output to a file for node-red running on ubuntu.
If you're running it as a service, then the console output will already be captured in /var/log/system.log - along with the log output from other services.
You can get a filtered view by using the node-red-log command - or, if you don't have that command, then you can use sudo journalctl -f -u nodered -o cat.
excellent. i am running Splunk Enterprise, so i will add /var/log/system.log as a monitored source.
i have been reading this morning about the logging section in settings.js and will likely do something there. but for now, this will get me what i need.
here is an example of a reference that says " For example, to redirect stdout to myapp.log , start the daemon with:" and gives this: " $ nohup node myapp.js > myapp.log"
but it doesn't say where to put the redirect. it is in my node-red.service? my settings.js?
But the easy way may be as Nick said - sudo journalctl -f -u nodered -o cat or maybe redirect that to a file sudo journalctl -f -u nodered -o cat > myfile.log
But if what you are really trying to do is log to splunk then it would probably be best to add a custom logger within settings.js to send the logs there directly.
This logs to syslog as node-red. I filter on this with rsyslogd. I think I created the user.progs directory with looser permission (1777) so that the user can write the PID file.
I found myself of need something similar to this as well. I'm running node-red container under ubuntu.
I wanted to capture the debug node "system console" to a file. When I check "system console" I can able to see the log from docker (using sudo docker logs node-red). How can I save those "system console" log from the debug node to a file?
System logging is managed by rsyslog, which can be configured to send the output from a specific app to a file, though I have not done it myself. No doubt a bit of research in this area would show you how.
Alternatively you could cheat and do it in node red by tailing syslog, selecting node red lines, and sending them to a file.