# Error log format

**URL:** <https://discourse.nodered.org/t/error-log-format/21839>\
**Category:** General\
**Created:** [17 February 2020 10:37 UTC](https://discourse.nodered.org/t/error-log-format/21839 "2020-02-17T10:37:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![stefano](https://avatars.discourse-cdn.com/v4/letter/s/aca169/32.png) [@stefano](https://discourse.nodered.org/u/stefano)\
**Post date:** [17 February 2020 10:37 UTC](https://discourse.nodered.org/t/error-log-format/21839/1 "2020-02-17T10:37:34Z")

</div>

I run node-red using pm2 and the errors are logged to .pm2/logs/node-red-error.log

For example:

`(node:10660) DeprecationWarning: PG.connect is deprecated - please see the upgrade guide at https://node-postgres.com/guides/upgrading`

**Question 1** : Is there a way to add a timestamp or better a date and time to the entries?

**Question 2** : if I do `grep 10660 .node-red/*` nothing is returned, where is this node defined?

---

<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:** [17 February 2020 14:29 UTC](https://discourse.nodered.org/t/error-log-format/21839/2 "2020-02-17T14:29:10Z")

</div>

Node-RED already includes a timestamp. Partial output of `pm2 logs`:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/d/8d8be1e9d5629dffa273384ed90076d6322b692f.png)

---

<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:** [17 February 2020 15:03 UTC](https://discourse.nodered.org/t/error-log-format/21839/3 "2020-02-17T15:03:11Z")

</div>

That warning had been logged by some piece of node.js code. It has been written directly to stdout of the node process, bypassing the Node-RED logging framework. That is why it looks "different" to normal NR log output.

The fact it mentions postgres should be the biggest clue for where it is coming from. What postgres node have you got installed? The message won't be coming from the NR node, but from the underlying postgres library module it is using.

---

<div class="post-metadata">

**Author:** ![stefano](https://avatars.discourse-cdn.com/v4/letter/s/aca169/32.png) [@stefano](https://discourse.nodered.org/u/stefano)\
**Post date:** [18 February 2020 09:25 UTC](https://discourse.nodered.org/t/error-log-format/21839/4 "2020-02-18T09:25:52Z")

</div>

Thanks for your reply @TotallyInformation , unfortunately there is no timestamp for the error log

```auto
/home/nodered/.pm2/logs/node-red-error.log last 15 lines:
0|node-red | (node:25266) DeprecationWarning: PG.connect is deprecated - please see the upgrade guide at https://node-postgres.com/guides/upgrading
0|node-red | (node:21253) DeprecationWarning: PG.connect is deprecated - please see the upgrade guide at https://node-postgres.com/guides/upgrading
0|node-red | (node:9248) DeprecationWarning: PG.connect is deprecated - please see the upgrade guide at https://node-postgres.com/guides/upgrading

```

I only see it for the out log:

```auto
/home/nodered/.pm2/logs/node-red-out.log last 15 lines:
0|node-red | 18 Feb 10:22:55 - [metric] {"level":99,"nodeid":"6c78f7cb.7c424","event":"node.json.send","msgid":"791ef036.27395","timestamp":1582017775148}

```

---

<div class="post-metadata">

**Author:** ![stefano](https://avatars.discourse-cdn.com/v4/letter/s/aca169/32.png) [@stefano](https://discourse.nodered.org/u/stefano)\
**Post date:** [18 February 2020 09:37 UTC](https://discourse.nodered.org/t/error-log-format/21839/5 "2020-02-18T09:37:43Z")

</div>

Hi @knolleary,

Thank you for your reply. Do you mean that node-red error.log reports errors and warnings from node.js? And this happens via pm2 in my case, bypassing node-red?

The warning I reported was just an example, the really important error is the following:

```auto
You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection:
Error: Connection refused: Not authorized
    at MqttClient._handleConnack (/home/nodered/.node-red/node_modules/mqtt/lib/client.js:920:15)
    at MqttClient._handlePacket (/home/nodered/.node-red/node_modules/mqtt/lib/client.js:350:12)
    at work (/home/nodered/.node-red/node_modules/mqtt/lib/client.js:292:12)
    at Writable.writable._write (/home/nodered/.node-red/node_modules/mqtt/lib/client.js:302:5)
    at doWrite (/home/nodered/.node-red/node_modules/readable-stream/lib/_stream_writable.js:428:64)
    at writeOrBuffer (/home/nodered/.node-red/node_modules/readable-stream/lib/_stream_writable.js:417:5)
    at Writable.write (/home/nodered/.node-red/node_modules/readable-stream/lib/_stream_writable.js:334:11)
    at Socket.ondata (_stream_readable.js:705:22)
    at Socket.emit (events.js:193:13)
    at Socket.EventEmitter.emit (domain.js:481:20)
(node:24363) UnhandledPromiseRejectionWarning: Error: Connection refused: Not authorized
    at MqttClient._handleConnack (/home/nodered/.node-red/node_modules/mqtt/lib/client.js:920:15)
    at MqttClient._handlePacket (/home/nodered/.node-red/node_modules/mqtt/lib/client.js:350:12)
    at work (/home/nodered/.node-red/node_modules/mqtt/lib/client.js:292:12)
    at Writable.writable._write (/home/nodered/.node-red/node_modules/mqtt/lib/client.js:302:5)
    at doWrite (/home/nodered/.node-red/node_modules/readable-stream/lib/_stream_writable.js:428:64)
    at writeOrBuffer (/home/nodered/.node-red/node_modules/readable-stream/lib/_stream_writable.js:417:5)
    at Writable.write (/home/nodered/.node-red/node_modules/readable-stream/lib/_stream_writable.js:334:11)
    at Socket.ondata (_stream_readable.js:705:22)
    at Socket.emit (events.js:193:13)
    at Socket.EventEmitter.emit (domain.js:481:20)

```

So this also comes from Node?

Thanks,  
Stefano

---

<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 February 2020 09:58 UTC](https://discourse.nodered.org/t/error-log-format/21839/6 "2020-02-18T09:58:52Z")

</div>

Yes, that has come directly from the node.js runtime and indicates a bug with a node - possibly the Mqtt nodes.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [18 April 2020 09:58 UTC](https://discourse.nodered.org/t/error-log-format/21839/7 "2020-04-18T09:58:56Z")

</div>

Closed on 18 April 2020 09:58 UTC

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
