vikt0rm / dbus-shelly-1pm-pvinverter

Integrate Shelly 1PM into Victron Energies Venus OS as a pv inverter
51 stars 57 forks source link

current.log is getting too big #4

Open e-i-k-e opened 2 years ago

e-i-k-e commented 2 years ago

Hello,

I noticed that the "current.log" file has grown to over 300 Mb in the meantime. Is there a possibility to limit the log file or that it cleans itself?

image

iz3man commented 1 year ago

This seems to be an issues with all those scripts based on the same work by @fabian-lauer ?! I got the issue with th goe-charger script.

This happens whenever something goes wrong an floods the log. It seems there is no log-rotate or some kind of logfile size check and auto dumping.

This is a serious issue, as, as soon as the file is >2Gb it can't be addressed by 32bit venusos anymore.

fabian-lauer commented 1 year ago

Ok - got it …. So we need a proper logging framework. Any recommendations for python?

iz3man commented 1 year ago

Sorry. No idea. I just discovered the issue. :(

fabian-lauer commented 1 year ago

Will try this one here after my vacation: https://www.blog.pythonlibrary.org/2014/02/11/python-how-to-create-rotating-logs/

currently no notebook in place 😎

iz3man commented 1 year ago

Nice. Yeah logrotate - no idea why it seems not to be inplemented in venusOS?! Enjoy your vacation - Viel Spass noch! :)

mascheihei commented 1 year ago

I have rotatelog already integrated. Will make a fork and and this

iz3man commented 1 year ago

Great! Will you post a link to the fork? Why not just update the original version? I think it's benefical (if not mandatory) for every user, as a not noticed error can render the whole partition unusable and unwriteable as it's 100% full.

mascheihei commented 1 year ago

I have created a pull request for the original fork. viktOrm can merge the changes into his main. I saw your bugreport and changed it 3 days ago before installing on the Cerbo of my friend. However: https://github.com/mascheihei/dbus-shelly-1pm-pvinverter

e-i-k-e commented 1 year ago

Is there a solution meanwhile?

My memory was full and VenusOS didn't run properly anymore because I had two log files with 2.2 and 3 GB each.

pau1phi11ips commented 1 year ago

@e-i-k-e just delete the logs files via SSH

e-i-k-e commented 1 year ago

@pau1phi11ips

Logical. But this does not permanently solve the problem.

mascheihei commented 1 year ago

@e-i-k-e and @pau1phi11ips

I tried with a pull request but it seems vikt=rm is gone ... Therefore I removed my fork.

With these changes you will get rotating logfiles for 7 days. the older log-files will be deleted.

adjust the following:

in line 5 after import logging add

from logging.handlers import TimedRotatingFileHandler

in main after line 194 insert log rotate handler and change logging.basic... as below. Not sure why with posting the file is changing. Please use the same as in the original. ` log_rotate_handler = TimedRotatingFileHandler("%s/current.log" % (os.path.dirname(os.path.realpath(file))), when="d", interval=1, backupCount=7)

logging.basicConfig(format='%(asctime)s,%(msecs)d %(name)s %(levelname)s %(message)s', datefmt='%Y-%m-%d %H:%M:%S', level=logging.INFO, handlers=[ logging.StreamHandler(), log_rotate_handler ]) `

vikt0rm commented 1 year ago

Sorry for being absent for so long time, now I started again maintaining the code. Since I finally got my Multiplus 2 5000, battery and final PV installation these days.

Will add the rotating log to my implementation, that is very good idea! Thanks for the hint!

ramack commented 1 year ago

Isn't there a somehow "standard" approach for logging (which would also end up in /var/log and probably using the strange timestamping you need tai64n for? - I didn't search but this driver is not the first one, so I guess the victron guys did their job here and you could "simply" reuse it.

mpvader commented 3 months ago

Hello all, yes there is a standard approach within Venus OS, which I’d really prefer that everyone sticks to. I’ve explained it here:

https://github.com/henne49/dbus-opendtu/issues/173

Todays current.log file approach is causing our users quite some headaches, and support issues sent to our distributors, and so forth.

Please help sort this sooner rather than later - thanks.