# How do I add user defined logs in log file

**URL:** https://discourse.nodered.org/t/how-do-i-add-user-defined-logs-in-log-file/64242
**Category:** General
**Tags:** function-node
**Created:** [22 June 2022 14:28 UTC](https://discourse.nodered.org/t/how-do-i-add-user-defined-logs-in-log-file/64242 "2022-06-22T14:28:18Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![MiliH](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@MiliH](https://discourse.nodered.org/u/MiliH)
#### Post date: [22 June 2022 14:28 UTC](https://discourse.nodered.org/t/how-do-i-add-user-defined-logs-in-log-file/64242/1 "2022-06-22T14:28:18Z")

</div>

Hello,  
I want to add logs to log file in Node-RED to check whether workflow is working properly.  
Can anyone help me out how to add logs.

Thank you!

---

<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: [22 June 2022 15:00 UTC](https://discourse.nodered.org/t/how-do-i-add-user-defined-logs-in-log-file/64242/2 "2022-06-22T15:00:50Z")

</div>

In a debug node, if you select output to console then it will be sent to the node red log, so will appear in the terminal running node-red. Is that good enough?  
Similarly, text output using `node.warn()` in a function node will appear there.

---

<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: [22 June 2022 15:12 UTC](https://discourse.nodered.org/t/how-do-i-add-user-defined-logs-in-log-file/64242/3 "2022-06-22T15:12:53Z")

</div>

In a function node, you can use `node.log` - annoyingly though, it only takes a single parameter and you have to flatten objects.

---

<div class="post-metadata">

### Author: ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)
#### Post date: [22 June 2022 15:30 UTC](https://discourse.nodered.org/t/how-do-i-add-user-defined-logs-in-log-file/64242/4 "2022-06-22T15:30:32Z")

</div>

...or use [node-red-contrib-flogger](https://flows.nodered.org/node/node-red-contrib-flogger)

---

<div class="post-metadata">

### Author: ![MiliH](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@MiliH](https://discourse.nodered.org/u/MiliH)
#### Post date: [23 June 2022 05:41 UTC](https://discourse.nodered.org/t/how-do-i-add-user-defined-logs-in-log-file/64242/5 "2022-06-23T05:41:08Z")

</div>

I want logs to be added in Notepad file.

Eg:. If I am sending email using email node then log should be added to log file that email is sent to respective person.

---

<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: [23 June 2022 07:50 UTC](https://discourse.nodered.org/t/how-do-i-add-user-defined-logs-in-log-file/64242/6 "2022-06-23T07:50:28Z")

</div>

So what do you need that is not supported by the flogger node?

---

<div class="post-metadata">

### Author: ![MiliH](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@MiliH](https://discourse.nodered.org/u/MiliH)
#### Post date: [23 June 2022 08:07 UTC](https://discourse.nodered.org/t/how-do-i-add-user-defined-logs-in-log-file/64242/7 "2022-06-23T08:07:23Z")

</div>

Flogger node is returning JSON type data. If there is any error occurred we cannot identify that error in log file that is generated using flogger.

---

<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: [23 June 2022 08:18 UTC](https://discourse.nodered.org/t/how-do-i-add-user-defined-logs-in-log-file/64242/8 "2022-06-23T08:18:51Z")

</div>

> [@MiliH](#):
>
> Flogger node is returning JSON type data

Do you mean this statement in the description is not correct?  
"You can define different output formats like plain textfile or JSON format "  
If so then I suggest you raise an issue against the bug.  
What have you got `Log Style` set to?

---

<div class="post-metadata">

### Author: ![MiliH](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@MiliH](https://discourse.nodered.org/u/MiliH)
#### Post date: [23 June 2022 09:45 UTC](https://discourse.nodered.org/t/how-do-i-add-user-defined-logs-in-log-file/64242/9 "2022-06-23T09:45:06Z")

</div>

I know that we can define different output formats in flogger but the format for that will be fixed. I want user defined format for log file.

---

<div class="post-metadata">

### Author: ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)
#### Post date: [23 June 2022 10:17 UTC](https://discourse.nodered.org/t/how-do-i-add-user-defined-logs-in-log-file/64242/10 "2022-06-23T10:17:13Z")

</div>

Well change the format before writing it to flogger as plain text.

---

<div class="post-metadata">

### Author: ![MiliH](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@MiliH](https://discourse.nodered.org/u/MiliH)
#### Post date: [23 June 2022 10:57 UTC](https://discourse.nodered.org/t/how-do-i-add-user-defined-logs-in-log-file/64242/11 "2022-06-23T10:57:38Z")

</div>

Where is output of node.log printed?

I mean if we are using node.warn output of that statement is printed in Debug window of node-red but where is output of node.log printed?

---

<div class="post-metadata">

### Author: ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)
#### Post date: [23 June 2022 14:54 UTC](https://discourse.nodered.org/t/how-do-i-add-user-defined-logs-in-log-file/64242/12 "2022-06-23T14:54:30Z")

</div>

> [@MiliH](#):
>
> Where is output of node.log printed?

Have a read of the user guide.  
[https://nodered.org/docs/user-guide/writing-functions#logging-events](https://nodered.org/docs/user-guide/writing-functions#logging-events)

---

<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: [7 July 2022 14:54 UTC](https://discourse.nodered.org/t/how-do-i-add-user-defined-logs-in-log-file/64242/13 "2022-07-07T14:54:52Z")

</div>

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