# Console and debug nodes output redirection to file or

**URL:** https://discourse.nodered.org/t/console-and-debug-nodes-output-redirection-to-file-or/2779
**Category:** General
**Created:** [2 September 2018 16:51 UTC](https://discourse.nodered.org/t/console-and-debug-nodes-output-redirection-to-file-or/2779 "2018-09-02T16:51:52Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![tilleul](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tilleul/32/78_2.png) [@tilleul](https://discourse.nodered.org/u/tilleul)
#### Post date: [2 September 2018 16:51 UTC](https://discourse.nodered.org/t/console-and-debug-nodes-output-redirection-to-file-or/2779/1 "2018-09-02T16:51:52Z")

</div>

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 `console.log()`, `node.log()`, `node.warn()`, `node.error()` command should also be redirected/duplicated ...

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [2 September 2018 17:07 UTC](https://discourse.nodered.org/t/console-and-debug-nodes-output-redirection-to-file-or/2779/2 "2018-09-02T17:07:34Z")

</div>

you can add your own custom logger - [https://nodered.org/docs/user-guide/logging](https://nodered.org/docs/user-guide/logging)

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [2 September 2018 17:49 UTC](https://discourse.nodered.org/t/console-and-debug-nodes-output-redirection-to-file-or/2779/3 "2018-09-02T17:49:19Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![tilleul](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tilleul/32/78_2.png) [@tilleul](https://discourse.nodered.org/u/tilleul)
#### Post date: [2 September 2018 18:13 UTC](https://discourse.nodered.org/t/console-and-debug-nodes-output-redirection-to-file-or/2779/4 "2018-09-02T18:13:39Z")

</div>

ok thanks to you both, this is a good starting point ... Sorry I completely overlooked that part of the docs ... 🤟

---

<div class="post-metadata">

### Author: ![athome](https://avatars.discourse-cdn.com/v4/letter/a/b77776/32.png) [@athome](https://discourse.nodered.org/u/athome)
#### Post date: [18 October 2018 19:24 UTC](https://discourse.nodered.org/t/console-and-debug-nodes-output-redirection-to-file-or/2779/5 "2018-10-18T19:24:53Z")

</div>

knolleary,

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.

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [18 October 2018 19:27 UTC](https://discourse.nodered.org/t/console-and-debug-nodes-output-redirection-to-file-or/2779/6 "2018-10-18T19:27:58Z")

</div>

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`.

---

<div class="post-metadata">

### Author: ![athome](https://avatars.discourse-cdn.com/v4/letter/a/b77776/32.png) [@athome](https://discourse.nodered.org/u/athome)
#### Post date: [18 October 2018 19:30 UTC](https://discourse.nodered.org/t/console-and-debug-nodes-output-redirection-to-file-or/2779/7 "2018-10-18T19:30:50Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![athome](https://avatars.discourse-cdn.com/v4/letter/a/b77776/32.png) [@athome](https://discourse.nodered.org/u/athome)
#### Post date: [18 October 2018 21:52 UTC](https://discourse.nodered.org/t/console-and-debug-nodes-output-redirection-to-file-or/2779/8 "2018-10-18T21:52:18Z")

</div>

knolleary,

[here is an example](https://help.papertrailapp.com/kb/configuration/configuring-centralized-logging-from-nodejs-apps/) 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!

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [18 October 2018 22:46 UTC](https://discourse.nodered.org/t/console-and-debug-nodes-output-redirection-to-file-or/2779/9 "2018-10-18T22:46:46Z")

</div>

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](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.

---

<div class="post-metadata">

### Author: ![ncherry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ncherry/32/27_2.png) [@ncherry](https://discourse.nodered.org/u/ncherry)
#### Post date: [27 October 2018 23:24 UTC](https://discourse.nodered.org/t/console-and-debug-nodes-output-redirection-to-file-or/2779/10 "2018-10-27T23:24:28Z")

</div>

Here is what I am currently using (Debian, Linux):

```auto
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.

---

<div class="post-metadata">

### Author: ![kanke](https://avatars.discourse-cdn.com/v4/letter/k/a698b9/32.png) [@kanke](https://discourse.nodered.org/u/kanke)
#### Post date: [19 January 2020 00:32 UTC](https://discourse.nodered.org/t/console-and-debug-nodes-output-redirection-to-file-or/2779/11 "2020-01-19T00:32:07Z")

</div>

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?

Thanks.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [19 January 2020 07:35 UTC](https://discourse.nodered.org/t/console-and-debug-nodes-output-redirection-to-file-or/2779/12 "2020-01-19T07:35:03Z")

</div>

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.
