# Logging node wanted

**URL:** <https://discourse.nodered.org/t/logging-node-wanted/65>\
**Category:** General\
**Created:** [10 May 2018 18:30 UTC](https://discourse.nodered.org/t/logging-node-wanted/65 "2018-05-10T18:30:12Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![igrowing](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/igrowing/32/663_2.png) [@igrowing](https://discourse.nodered.org/u/igrowing)\
**Post date:** [10 May 2018 18:30 UTC](https://discourse.nodered.org/t/logging-node-wanted/65/1 "2018-05-10T18:30:12Z")

</div>

Hi, node-red newbie is here.

There is logging settings in .node-red/settings.js. The configuration of its 3 properties is clear. An ability of adding of custom logger is clear.

I wonder if the built-in logging saves any log-file? If yes, where? If no, is there something to enable/configure to log events at info-level?

---

<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:** [10 May 2018 19:14 UTC](https://discourse.nodered.org/t/logging-node-wanted/65/2 "2018-05-10T19:14:33Z")

</div>

The default logging just writes to the standard output stream of the node process. Where that ends up will depend on how you are running node-red and where that redirects the standard output to.

---

<div class="post-metadata">

**Author:** ![igrowing](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/igrowing/32/663_2.png) [@igrowing](https://discourse.nodered.org/u/igrowing)\
**Post date:** [11 May 2018 11:54 UTC](https://discourse.nodered.org/t/logging-node-wanted/65/3 "2018-05-11T11:54:50Z")

</div>

OK. Normally I run the node-red from shell as:

```
node-red-start

```

When it stops printing and the frontend appears in browser I press Ctrl+C in shell. Then the node-red works in background. Where the stdout is printed to and how to keep/redirect it?  
Can this be good enough to keep the stdout in nohup.out:

```
nohup node-red-start &
```

---

<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:** [11 May 2018 12:19 UTC](https://discourse.nodered.org/t/logging-node-wanted/65/4 "2018-05-11T12:19:38Z")

</div>

If you are running on a Raspberry Pi, you should find you have the command `node-red-log` available. This can be used to view the log.

Under the covers, Node-RED is being run as system process, logging to `/var/log/system.log` along with other processes. The `node-red-log` command provides a filtered view of just the Node-RED log output.

---

<div class="post-metadata">

**Author:** ![igrowing](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/igrowing/32/663_2.png) [@igrowing](https://discourse.nodered.org/u/igrowing)\
**Post date:** [11 May 2018 15:08 UTC](https://discourse.nodered.org/t/logging-node-wanted/65/5 "2018-05-11T15:08:49Z")

</div>

Indeed, I forgot to mention the node-red is running on RasPi.  
node-red-log is useful for current debug: it is showing few last events and prints new events. Thank you. Good for debug.  
However, it’s blocking shell and not full log.

I have added in my RasPi following command under an alias which shows one line per event of full log and non-blocking. Maybe useful for someone 🙂

```
 grep "Node-RED" /var/log/syslog | sed "s/^.*Node-RED\[[0-9]*\]: //g" | paste -d ' ' - -

```

I think the topic is SOLVED:  
Wire required events or node output into debug node. That’s enough for logging. And 2 useful ways to see the log exist.

---

<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:** [11 May 2018 15:49 UTC](https://discourse.nodered.org/t/logging-node-wanted/65/6 "2018-05-11T15:49:07Z")

</div>

If you look at the `node-red-log` command all it is doing is  
`sudo journalctl -f -n 25 -u nodered -o cat`  
which bascially prints the last 25 lines and then tails the log for more… you can instead just  
`sudo journalctl -u nodered -o cat`  
which will just print all the existing node-red entires in the log  
(other parameters / options are available 🙂

---

<div class="post-metadata">

**Author:** ![igrowing](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/igrowing/32/663_2.png) [@igrowing](https://discourse.nodered.org/u/igrowing)\
**Post date:** [11 May 2018 16:46 UTC](https://discourse.nodered.org/t/logging-node-wanted/65/7 "2018-05-11T16:46:12Z")

</div>

Use of `journalcrl` seems to be pretty effective. However, I like to see 1 event per line.  
So I wrote tiny script, called it `nrl` (brief from node-red-log) and placed it into `/usr/local/bin/`.  
Upload of the script doesn’t work here (only pictures allowed). So sharing it as text.

```
#!/usr/bin/python
''' Node-RED log parser.

    Authors: igrowing

'''

import re
import os

DATE_PTN = '(?sm)\w+ \w+ \d+:\d+:\d+.+?(?=\w+ \w+ \d+:\d+:\d+|}$)'

log = os.popen('grep "Node-RED" /var/log/syslog | sed "s/^.*Node-RED\[[0-9]*\]: //g"').read()
recs = re.findall(DATE_PTN, log)
for rec in recs:
    rec = rec.replace('\n', ' ')
    print rec + '}' if '{' in rec else rec
```

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [11 May 2018 17:23 UTC](https://discourse.nodered.org/t/logging-node-wanted/65/8 "2018-05-11T17:23:05Z")

</div>

Actually, there is a fair bit you can do to format the output. See: [https://www.freedesktop.org/software/systemd/man/journalctl.html](https://www.freedesktop.org/software/systemd/man/journalctl.html)

Maybe add `-o short` or `-o short-full` to the command, that should get to single line entries.
