# Writing general log to file

**URL:** <https://discourse.nodered.org/t/writing-general-log-to-file/101830>\
**Category:** General\
**Created:** [27 September 2026 09:26 UTC](https://discourse.nodered.org/t/writing-general-log-to-file/101830 "2026-09-27T09:26:53Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![khfischbach](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/khfischbach/32/16627_2.png) [@khfischbach](https://discourse.nodered.org/u/khfischbach)\
**Post date:** [27 September 2026 09:26 UTC](https://discourse.nodered.org/t/writing-general-log-to-file/101830/1 "2026-09-27T09:26:53Z")

</div>

Hi,  
I would like to enable nr to log to a file and to syslog.

I found in the net a post to do it this like in the settings.js:

```auto
     logging: {
         /** Only console logging is currently supported */
         console: {
             /** Level of logging to be recorded. Options are:
              * fatal - only those errors which make the application unusable should be recorded
              * error - record errors which are deemed fatal for a particular request + fatal errors
              * warn - record problems which are non fatal + errors + fatal errors
              * info - record information about the general running of the application + warn + error + fatal errors
              * debug - record information which is more verbose than info + info + warn + error + fatal errors
              * trace - record very detailed logging + debug + info + warn + error + fatal errors
              * off - turn off all logging (doesn't affect metrics or audit)
              */
             level: "info",
             /** Whether or not to include metric events in the log output */
             metrics: false,
             /** Whether or not to include audit events in the log output */
             audit: false
         },
         file: {
           level: "debug",
           audit: true,
           filename: "/var/log/nodered.log"
         }
     },

```

But it does not seem to work.  
I would like to log login attempts to the file.

Is there any way to get this working. I am not realy able to write a customlogger.

Thanks  
Karl-Heinz

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [27 September 2026 11:49 UTC](https://discourse.nodered.org/t/writing-general-log-to-file/101830/2 "2026-09-27T11:49:39Z")

</div>

Does the directory /var/log exist?

Whereabouts is this settings.js file? What directory is it in?

Did you restart node-red after changing this settings file?

---

<div class="post-metadata">

**Author:** ![hardillb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hardillb/32/12373_2.png) [@hardillb](https://discourse.nodered.org/u/hardillb)\
**Post date:** [27 September 2026 13:28 UTC](https://discourse.nodered.org/t/writing-general-log-to-file/101830/3 "2026-09-27T13:28:54Z")

</div>

And more importantly by default only `root` (and possibly the `syslog` group) can write to `/var/log` and you **REALLY REALLY** should not be running Node-RED as `root` without a **VERY** clear understanding of what you are doing.

---

<div class="post-metadata">

**Author:** ![khfischbach](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/khfischbach/32/16627_2.png) [@khfischbach](https://discourse.nodered.org/u/khfischbach)\
**Post date:** [27 September 2026 13:35 UTC](https://discourse.nodered.org/t/writing-general-log-to-file/101830/4 "2026-09-27T13:35:36Z")

</div>

Hi,

1. /var/log is the standard directory of ubuntu to store logfiles. So it exists!
2. the settings.js is in the directory .node-red of the user where node-red runs.
3. yes, the user can write to the directory and the logfile. I checked it by "echo 'xxx'\>\>/var/log/nodered.log" from the user where nodered runs and I did not receive any errormessage. Naturally the text was in the logfile - I checked that.
4. yes, I restarted nodered

---

<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:** [27 September 2026 13:59 UTC](https://discourse.nodered.org/t/writing-general-log-to-file/101830/5 "2026-09-27T13:59:20Z")

</div>

> [@khfischbach](#):
>
> 1. yes, the user can write to the directory and the logfile. I checked it by "echo 'xxx'\>\>/var/log/nodered.log" from the user where nodered runs and I did not receive any errormessage.

Did you manually create the log file with the appropriate permissions or did it just work? node red should not be able to create a file there.

Did you add that whole section into settings.js or did you edit the existing settings for logging and just add the `file:` section?

---

<div class="post-metadata">

**Author:** ![hardillb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hardillb/32/12373_2.png) [@hardillb](https://discourse.nodered.org/u/hardillb)\
**Post date:** [27 September 2026 14:05 UTC](https://discourse.nodered.org/t/writing-general-log-to-file/101830/6 "2026-09-27T14:05:10Z")

</div>

Hang on, I'm 99.5% sure there is no built in logging to file in Node-RED, you need to write your own custom logging plugin using the API described here:

> **[Logging : Node-RED](https://nodered.org/docs/user-guide/runtime/logging)**

---

<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:** [27 September 2026 14:16 UTC](https://discourse.nodered.org/t/writing-general-log-to-file/101830/7 "2026-09-27T14:16:04Z")

</div>

I have used node-red-contrib-flogger in the past and found it useful. It is old but still installs ok.

By default node-red will log to the system journal from debug nodes and methods such as `node.warn()` in function nodes. You can use `journalctl` to access the system journal.

---

<div class="post-metadata">

**Author:** ![khfischbach](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/khfischbach/32/16627_2.png) [@khfischbach](https://discourse.nodered.org/u/khfischbach)\
**Post date:** [27 September 2026 14:28 UTC](https://discourse.nodered.org/t/writing-general-log-to-file/101830/8 "2026-09-27T14:28:32Z")

</div>

1. I manually created the file with the appropriate permissions and tested it as described.
2. I only added the section with `file:` to the settings.js

---

<div class="post-metadata">

**Author:** ![khfischbach](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/khfischbach/32/16627_2.png) [@khfischbach](https://discourse.nodered.org/u/khfischbach)\
**Post date:** [27 September 2026 14:32 UTC](https://discourse.nodered.org/t/writing-general-log-to-file/101830/9 "2026-09-27T14:32:14Z")

</div>

If I am not wrong, this will log actions from some nodes inside node-red.  
But I want to log all loggings to the file. Everything what currently will get logged to syslog.

But, I think, according to @hardillb, the post I read somewhere how to add the `file:`-section to the settings.js will not work at all since, if i understand @hardillb correct, node-red does only log to "console" or "customlogger".

So the post I followed from somewhere was pobably missleading.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [27 September 2026 15:28 UTC](https://discourse.nodered.org/t/writing-general-log-to-file/101830/10 "2026-09-27T15:28:47Z")

</div>

How do you start Node-red running?

If it is a systemd service you can add this to the [service] section of nodered.service:

```auto
StandardOutput=append:/var/log/nrlogfile.log
StandardError=append:/var/log/nrlogfile.log

```

You probably want to arrange the logfiles to be included in standard log rotation (assuming Ubuntu does this). Some of the logging levels in settings.js result in a lot of output!

---

<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:** [27 September 2026 17:18 UTC](https://discourse.nodered.org/t/writing-general-log-to-file/101830/11 "2026-09-27T17:18:50Z")

</div>

Are you running under systemd?

If so, by default (on Debian and derivations anyway), systemd has its own logging BUT the logs are sync'd to syslog as far as I remember. Oh, actually Debian ships with a tool that does the sync, other distro's might not do that by default.

Systemd journals (logs) write to `/var/log/journal/.....` The files are by source user:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/e/ce5f16143dd6066ff8ca8f4727a426be51a29b2a.png)  
The files are not text though.

As jbudd has said, you _can_ also tell systemd to output to specific log files. However, I don't think those will then rotate and so you will need to do something to control the size. journald also keeps the files locked open so rotating them may be complex.

Similarly, if you roll your own logs using Node-RED's settings, you must also handle your own rotation/clear-down.

Best bet is to sync the journald logs to syslog.

Personally, I find that the only reason to roll your own Node-RED log is for some special purpose. For example, I have a special log function on my dev instance that outputs trace level outputs for uibuilder but info level for everything else. Also, I don't write that to file, I send each output to MQTT and I have a flow and uibuilder-driven web page to show the logs.
