Is it possible to redirect (or preferably duplicate) console and debug nodes output to a file or something else like a DB or anything ... ?
It means that any
node.error() command should also be redirected/duplicated ...
Or, if you just want it written to a file, depending on how you run node-red, you can just redirect it's console output to a file.
ok thanks to you both, this is a good starting point ... Sorry I completely overlooked that part of the docs ...
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.
thanks in advance.
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.
thank you for the quick response.
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?
know what I mean, vern!
As we use systemd for running it as a service then you may want to read this - https://stackoverflow.com/questions/37585758/how-to-redirect-output-of-systemd-service-to-a-file
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.
Here is what I am currently using (Debian, Linux):
daemon --name=node-red --pidfile=/var/run/user.progs/node-red.pid /usr/local/bin/node-red
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.