Hi! I'm sure soeone esle has already asked about this in past, but googling it I can't find a proper answer, also searching here in the forum.
THis night my Raspberry for the first time had a problem, the IP protocol stopped somehow, I guess it's a kernel problem, this morning the ping worked but I can't open more node red page, not SSH and Alexa can't connect to the mapped port 80.
I reboot it and in var/logs i the messages file I have:
eb 7 04:33:49 raspberrypi kernel: [204905.473054] Voltage normalised (0x00000000)
******************************************* Feb 7 12:52:25 raspberrypi mtp-probe: checking bus 1, device 3: "/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.1"
Feb 7 12:52:25 raspberrypi mtp-probe: bus: 1, device: 3 was not an MTP device
Where I wrote ******** I have 2 lines of NUL chars, I can't type them here.
I would like to read the log file of Node Red, where this file is? Which path? Thanks.
I also would like to log qite everything, of the last 48hours, if it possible to do. To don't have big impact on the system I would like to delete logs before 48 hours, is it possible to do?
Mayb the idea is to create a file for every day and tell Node Red to delete previous files every day. It's really useful for debugging
Thank you for help!
The log file location depends on how you run Node-RED. For example if you run Node-RED using pm2 it will be different that if you run straight from the command line.
If you are using the pi install you can run the command as listed on the raspberry pi page in the docs.
You can change the amount of logging in your settings.js file again the docs explain how.
As they use the systems logging they will automatically get cleaned up.
I used sudo systemctl enable nodered.service as in the main instructions, I installed node red without root, where are log files? what names they have? only console.log?
if you have followed the Raspberry Pi install docs here: https://nodered.org/docs/hardware/raspberrypi then, as described on that page, then you should also have the node-red-log command.
But if you haven't used our install script, you won't have that command. In which case, you should be able to use
both of them working, thank you, but I can see only data only from the last time it started. Any chances to see the contant of the file with old logs? I need to know what happeed this night.
Maybe as default Node red doesn't log to file, and add history at avery restart (instead of delete all previous data). How to have this journal then?
When running as a service, the log is entirely managed by journald outside of node-red. I haven't looked at what configuration options it provides, but I assume it must provide options to extend the history it keeps. A quick google on the topic finds this: https://www.loggly.com/ultimate-guide/linux-logging-with-systemd/ which may help you.
Colin thanks, yes there I can see all, mixed up. For me it's ok since I can see what happened in the night. It's not Node red (but it was working instead), it was the kernel, the IP TCP was not more working and also logging was stopped, so I don't have many elements..
I add this to my package.json file scripts section so that I can run the command npm run log. That way I don't have to remember the ugly, complex command.
If you are feeling adventurous, you could easily amend your systemd node-red startup script to redirect output to a different log file in /var/logs/ I think that journalctl will pick that up automatically - if not, you would need to alter its config if you needed that. You should also look at /etc/logrotate.conf to make sure your node-red logs get rotated otherwise they will keep growing. (the default setup is rotated automatically).
Just a short feedback from me, I've found very useful to read the whole Raspberry log, so I can also check how the system is working, not only Node Red, anyway to filter it I've founf useful the suggestions here, with a small change.
sudo journalctl -n 30 -u nodered -o cat
where 30 is the last 30 lines logged from Node Red, change the number as your needs. it seems keep also the console on the logging and if something is incoming it will show you, to exit press control+C.
Thank you