# Function node's OnStart - no logging possible?

**URL:** <https://discourse.nodered.org/t/function-nodes-onstart-no-logging-possible/68456>\
**Category:** General\
**Tags:** function-node\
**Created:** [1 October 2022 15:19 UTC](https://discourse.nodered.org/t/function-nodes-onstart-no-logging-possible/68456 "2022-10-01T15:19:19Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![NodeWrangler](https://avatars.discourse-cdn.com/v4/letter/n/e9bcb4/32.png) [@NodeWrangler](https://discourse.nodered.org/u/NodeWrangler)\
**Post date:** [1 October 2022 15:19 UTC](https://discourse.nodered.org/t/function-nodes-onstart-no-logging-possible/68456/1 "2022-10-01T15:19:19Z")

</div>

Hy all,

I am relatively new to NodeRED and tinker around with function nodes.

As I wasn't to sure about the flow context concept, I tried to add debug lines into my node's OnStartup, but they nowhere appeared in the debug window.

Although I use the selected node context, debug messages from the same nodes OnMessage tab appear as expected in the debug window.

Am I missing something, or is debugging in the OnStartup really not possible?

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:** [1 October 2022 19:01 UTC](https://discourse.nodered.org/t/function-nodes-onstart-no-logging-possible/68456/2 "2022-10-01T19:01:25Z")

</div>

Welcome to the forum @NodeWrangler

> [@NodeWrangler](#):
>
> I tried to add debug lines into my node's OnStartup

What sort of debug lines? If you mean you used `console.log()` then possibly they do not appear in the debug pane because they are run before node-red is fully started so the output gets lost. If you look in the node-red log you should see them.

---

<div class="post-metadata">

**Author:** ![NodeWrangler](https://avatars.discourse-cdn.com/v4/letter/n/e9bcb4/32.png) [@NodeWrangler](https://discourse.nodered.org/u/NodeWrangler)\
**Post date:** [2 October 2022 09:55 UTC](https://discourse.nodered.org/t/function-nodes-onstart-no-logging-possible/68456/3 "2022-10-02T09:55:37Z")

</div>

Thanks for chiming in.

I ment node.log() statements. But it makes sense, they might not show up as NR is no started fully yet, when they are started.

---

<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:** [2 October 2022 10:05 UTC](https://discourse.nodered.org/t/function-nodes-onstart-no-logging-possible/68456/4 "2022-10-02T10:05:17Z")

</div>

If you use console.log() and look in the log as I suggested and it should be ok. I don't know what node.log() will do in this situation.

---

<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 October 2022 10:43 UTC](https://discourse.nodered.org/t/function-nodes-onstart-no-logging-possible/68456/5 "2022-10-02T10:43:51Z")

</div>

`node.log` does not write to the debug sidebar at any time. It only writes to the console log.

You can use `node.warn` to write to the debug sidebar at any time.

There have been discussions in the past on giving the Function node a better logging API for the debug sidebar (rather than having to log everything as a warning). But not come to any final conclusion or contribution to make it so.

---

<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:** [2 October 2022 10:59 UTC](https://discourse.nodered.org/t/function-nodes-onstart-no-logging-possible/68456/6 "2022-10-02T10:59:34Z")

</div>

> [@knolleary](#):
>
> But not come to any final conclusion or contribution to make it so.

Is there a design discussion somewhere that people could contribute to?

---

<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 October 2022 11:13 UTC](https://discourse.nodered.org/t/function-nodes-onstart-no-logging-possible/68456/7 "2022-10-02T11:13:13Z")

</div>

I think this was the last discussion on it [📋 Survey: logging to debug sidebar](https://discourse.nodered.org/t/survey-logging-to-debug-sidebar/21253)

---

<div class="post-metadata">

**Author:** ![NodeWrangler](https://avatars.discourse-cdn.com/v4/letter/n/e9bcb4/32.png) [@NodeWrangler](https://discourse.nodered.org/u/NodeWrangler)\
**Post date:** [2 October 2022 11:15 UTC](https://discourse.nodered.org/t/function-nodes-onstart-no-logging-possible/68456/8 "2022-10-02T11:15:25Z")

</div>

Thanks for clarifying this issue.

---

<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:** [1 December 2022 11:16 UTC](https://discourse.nodered.org/t/function-nodes-onstart-no-logging-possible/68456/9 "2022-12-01T11:16:00Z")

</div>

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