# Debug Node output to Logagent or Logstash

**URL:** <https://discourse.nodered.org/t/debug-node-output-to-logagent-or-logstash/30706>\
**Category:** General\
**Created:** [25 July 2020 22:40 UTC](https://discourse.nodered.org/t/debug-node-output-to-logagent-or-logstash/30706 "2020-07-25T22:40:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Charry2014](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/charry2014/32/46308_2.png) [@Charry2014](https://discourse.nodered.org/u/Charry2014)\
**Post date:** [25 July 2020 22:40 UTC](https://discourse.nodered.org/t/debug-node-output-to-logagent-or-logstash/30706/1 "2020-07-25T22:40:54Z")

</div>

Can anyone point me in the right direction here - I would like to write some debug and monitoring messages to an external log collection tool (Sematext through their Logagent shipper) and have got a bit confused. There are a few [projects](https://sematext.com/blog/iot-air-pollution-tracking-with-node-js-elastic-stack-and-mqtt/) doing similar stuff but from what I have found what I am after.

Writing logs to Logagent is pretty straightforward - a PUT or a POST or many other possibilities - but how to get the debug node to do this?

---

<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:** [25 July 2020 22:50 UTC](https://discourse.nodered.org/t/debug-node-output-to-logagent-or-logstash/30706/2 "2020-07-25T22:50:22Z")

</div>

Easiest would be to create your own custom log handler [https://nodered.org/docs/user-guide/runtime/logging](https://nodered.org/docs/user-guide/runtime/logging)

---

<div class="post-metadata">

**Author:** ![Charry2014](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/charry2014/32/46308_2.png) [@Charry2014](https://discourse.nodered.org/u/Charry2014)\
**Post date:** [26 July 2020 11:14 UTC](https://discourse.nodered.org/t/debug-node-output-to-logagent-or-logstash/30706/3 "2020-07-26T11:14:38Z")

</div>

Thanks - I saw that, is there some more detailed instructions about how to get started with this?

Specific questions:

How best do you debug custom logger code? I added that code to my settings.js, restarted Node Red and ... nothing. It seems if I have an error in the code Node Red won't start, if I remove it then Node Red starts again. But I see no output to say where the error may be.

Then once I get the logger integrated how do I use it? Does it show as a node or is it another output destination offered to all debug nodes?

---

<div class="post-metadata">

**Author:** ![Charry2014](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/charry2014/32/46308_2.png) [@Charry2014](https://discourse.nodered.org/u/Charry2014)\
**Post date:** [31 July 2020 08:06 UTC](https://discourse.nodered.org/t/debug-node-output-to-logagent-or-logstash/30706/4 "2020-07-31T08:06:36Z")

</div>

Hello everyone - can anyone help me with these two specific questions? I am struggling to make progress.

How best do you debug custom logger code? I added that code to my settings.js, restarted Node Red and ... nothing. It seems if I have an error in the code Node Red won't start, if I remove it then Node Red starts again. But I see no output to say where the error may be.

Then once I get the logger integrated how do I use it? Does it show as a node or is it another output destination offered to all debug nodes?

Thanks in advance.

---

<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:** [31 July 2020 08:49 UTC](https://discourse.nodered.org/t/debug-node-output-to-logagent-or-logstash/30706/5 "2020-07-31T08:49:31Z")

</div>

generally it means that the file is no longer valid js so usually a good linter will highlight the error that stops it starting.

Once running it runs in parallel with other loggers (unless you turn them off) so any write to log will call your code.

---

<div class="post-metadata">

**Author:** ![Charry2014](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/charry2014/32/46308_2.png) [@Charry2014](https://discourse.nodered.org/u/Charry2014)\
**Post date:** [13 August 2020 21:30 UTC](https://discourse.nodered.org/t/debug-node-output-to-logagent-or-logstash/30706/6 "2020-08-13T21:30:28Z")

</div>

Many thanks for the hints, unfortunately this turned out to be too time-consuming so I gave up with this approach and instead captured the output from the Docker containers and spooled them to Sematext throught a Logagent container. Anyone who is interested can see the containers in my [Github](https://github.com/Charry2014/balena-node-red-raspberry-pi-gpio).

---

<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:** [12 October 2020 21:30 UTC](https://discourse.nodered.org/t/debug-node-output-to-logagent-or-logstash/30706/7 "2020-10-12T21:30:39Z")

</div>

Closed on 12 October 2020 21:30 UTC

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