Unofficial log file? openaq.log

On my RasPi running Node-Red, I recently discovered ~/.node-red/openaq.log mainly as it was taking up a bunch of space :slight_smile: I had changed my logging level when looking into a previous issue I was having with Node-Red that I was troubleshooting from the console. The Pi I run on is headless so I run Node-Red as a service and I never saw any of the console log info show up in the output of the node-red-log command so I assumed leaving the logging enabled was harmless. This isn't the case, but it is also a potentially useful tool for anyone else who could use something other than console logging.

What I would like to learn is if this file is being created because I'm running Node Red as a Linux service on a Raspberry Pi or if there is some other condition that causes it to be created.
This file doesn't appear to get mentioned in the documentation (at least a google search for openaq.log didn't get any hits before I made this post).

I hope we might eventually see something like this officially supported along with being able to specify the location and maximum size for the file. Now that I've stumbled onto this log, it's going to be really useful in helping me track down some intermittent issues. I hope others find it useful too.

Do you have the node node-red-contrib-openaq installed?
(found using a google search 'node-red openaq')

Looks like it though no nodes are configured or deployed.
I'll go to their github page and ask about this behavior, it seems like it is potentially unintended.

Also in my defense, I was looking for the exact phrase openaq.log along with node-red which doesn't turn much up. There is a singular hit of a forum post here in the forums but it only pops up as part of a file listing.

Go to Configuration Nodes in the menus and click Unused. Check for an aq node there and delete it if found.

I double checked that before I made my response thinking that it may have been some cruft left over from when I was trying some AQI experiments a while ago.

I also went ahead and changed my logging level in Node-Red then restarted the service and now I no longer have the .log file. I tried setting it back and restarting node-red again and the file still hasn't been recreated.

I may have hit some sort of weird bug that I can't recreate. It's kind of a shame I can't recreate it because having a way to get detailed data out to a file when running node-red as a service would really help in my efforts to track down an intermittent issue I'm seeing when interfacing with some cloud services.

Had you restarted node-red since you deleted any config nodes related to that node?

Setting what back? Do you mean configuring an aq node again?


Some time ago I had issues with the OpenAQ log file as well. See: Google Log in failed · Issue #241 · mikejac/node-red-contrib-google-smarthome · GitHub

My post of February 1st. 2022

Sorry for the lack of clarity, I set the logging level back to trace on the off chance that's what triggered the issue.

I might revisit this later (especially since that seemed to be the only way to get my node.warn() messages, debug node output, and error messages that will pop up in the side bar logged to a file when running Node-Red as a service) but if no one else is reporting an issue then I don't see too much reason to pursue this further.

They get logged to the node-red log file. The default service file for a pi sends that to syslog, but it is configurable in the service file I believe. Alternatively you can see the node-red log in the terminal using node-red-log or journalctl -u nodered. At least you should be able to now that you have got rid of the problem triggered by the aq node, whatever that was.

Alternatively you can use a custom logger as described in Logging : Node-RED

Basically, all the messages I get from node red are this:

28 Oct 09:37:03 - [debug] Module: node-red-contrib-moment 4.0.0 /home/pi/.node-red/node_modules/node-red-contrib-moment
28 Oct 09:37:03 - [debug] Module: node-red-contrib-moving-average 1.3.0 /home/pi/.node-red/node_modules/node-red-contrib-moving-average
28 Oct 09:37:03 - [debug] Module: node-red-contrib-openaq 0.0.5 /home/pi/.node-red/node_modules/node-red-contrib-openaq
28 Oct 09:37:03 - [debug] Module: node-red-contrib-play-audio 2.5.0 /home/pi/.node-red/node_modules/node-red-contrib-play-audio
28 Oct 09:37:03 - [debug] Module: node-red-contrib-polymer 0.0.22 /home/pi/.node-red/node_modules/node-red-contrib-polymer
28 Oct 09:37:03 - [debug] Module: node-red-contrib-semaphore 1.0.1 /home/pi/.node-red/node_modules/node-red-contrib-semaphore
28 Oct 09:37:03 - [debug] Module: node-red-contrib-smb 1.2.0 /home/pi/.node-red/node_modules/node-red-contrib-smb
28 Oct 09:37:03 - [debug] Module: node-red-contrib-tplink 1.0.0 /home/pi/.node-red/node_modules/node-red-contrib-tplink
28 Oct 09:37:03 - [debug] Module: node-red-contrib-tplink-iot 0.1.8 /home/pi/.node-red/node_modules/node-red-contrib-tplink-iot
28 Oct 09:37:03 - [debug] Module: node-red-contrib-ui-artless-gauge 0.3.11 /home/pi/.node-red/node_modules/node-red-contrib-ui-artless-gauge
28 Oct 09:37:03 - [debug] Module: node-red-contrib-ui-led 0.4.9 /home/pi/.node-red/node_modules/node-red-contrib-ui-led
28 Oct 09:37:03 - [debug] Module: node-red-contrib-unit-converter 0.0.2 /home/pi/.node-red/node_modules/node-red-contrib-unit-converter
28 Oct 09:37:03 - [debug] Module: node-red-contrib-viseo-google-authentication 0.1.1 /home/pi/.node-red/node_modules/node-red-contrib-viseo-google-authentication
28 Oct 09:37:03 - [debug] Module: node-red-contrib-viseo-google-spreadsheet 0.5.1 /home/pi/.node-red/node_modules/node-red-contrib-viseo-google-spreadsheet
28 Oct 09:37:03 - [debug] Module: node-red-contrib-wellness 0.0.10 /home/pi/.node-red/node_modules/node-red-contrib-wellness
28 Oct 09:37:03 - [debug] Module: node-red-dashboard 2.28.2 /home/pi/.node-red/node_modules/node-red-dashboard
28 Oct 09:37:03 - [debug] Module: node-red-hxtx-ftp 0.0.14 /home/pi/.node-red/node_modules/node-red-hxtx-ftp
28 Oct 09:37:03 - [debug] Module: node-red-node-pi-gpio 1.2.3 /home/pi/.node-red/node_modules/node-red-node-pi-gpio
28 Oct 09:37:03 - [debug] Module: node-red-node-ping 0.3.1 /home/pi/.node-red/node_modules/node-red-node-ping
28 Oct 09:37:03 - [debug] Module: node-red-node-pushover 0.0.24 /home/pi/.node-red/node_modules/node-red-node-pushover
28 Oct 09:37:03 - [debug] Module: node-red-node-random 0.4.0 /home/pi/.node-red/node_modules/node-red-node-random
28 Oct 09:37:03 - [debug] Module: node-red-node-serialport 0.14.1 /home/pi/.node-red/node_modules/node-red-node-serialport
28 Oct 09:37:03 - [debug] Module: node-red-node-smooth 0.1.2 /home/pi/.node-red/node_modules/node-red-node-smooth
28 Oct 09:37:03 - [debug] Module: node-red-node-ui-lineargauge 0.3.6 /home/pi/.node-red/node_modules/node-red-node-ui-lineargauge
/bin/sh: 1: /home/pi/.node-red/node_modules/node-red-node-pi-gpio/ not found

Is there some additional config to make errors show up there? What about my node.warn() messages? For debug nodes, I do see the option to send the message to the console but I'm looking to get more than that. I have done some quick tests with node.log(), node.warn(), node.error(), node.trace(), and node.debug() but I don't see any of those messages when run node-red-log, journalctl -u nodered, or cat /var/log/syslog | grep <my unique message string>

I am investigating writing a custom logger. I have been looking for some solid examples of using the Javascript FS library since I'm new to it. But from some quick reading of the documents I'm not sure using that in settings.js is a great idea. I don't see an obvious way to make sure a file handle is released on node-red exiting and the asynchronous nature of the library looks like another challenge to handle correctly in a custom logger. If you have some solid examples of custom logger and any advice on the node.js fs library (or an alternative) I could really use some input :slight_smile:

You are getting all those debug messages because, I assume, you have set the log level to debug. The normal setting is info so I suggest setting it to that.
I have just tested with an inject node feeding a Function node containing

node.warn("Warning from Test function")
return msg;

Running node-red-log (which uses journalctl) then when I click the inject I see
28 Oct 18:46:07 - [warn] [function:Test function] Warning from Test function

That also works with log level debug.

If that doesn't work can you run
and post the full output from the start here, including clicking the inject a few times. Probably best to drop the log level to info first.

I'd like to move this discussion to this thread.