I’ve found a lot of topics about limiting the size of this file, but most seem to only talk about command line options, like --log-rotate-days. I run HA from a docker-compose file, so AFAIK, I can’t use command line options.
So, to keep it short:
In 2023, running HA in a Docker container, how do we limit the size of the home-assistant.log file found in the config folder?
Well, I’d say that if everything work fine, log file is not getting large enough to rotate it between restarts (accompanying core updates). If it goes big, then most likely there is some prblem in configuration/setup, that causes so many lines to be recorded and eliminating these errors should be the focus. Said that all I did was to set default logging level to warning and set it to error for some integrations that throws some warning messages, even if work perfectly and there is nothing to be done. After that if I see that my log is more than 50 lines long I know I need to dig into details…
While that may be true, it’s not the answer to my question (well it is, since I asked about limiting the size of the log, but I meant limiting as in doing something when it reaches a certain size). Limiting the amount of input the log gets doesn’t prevent it from growing too large, it only extends the amount of time it takes to reach the problematic size. That being said, I did have an excessive amount of debug logging in there that was completely unnecessary.
I still think there should be a way to rotate the log file though. The question is: Is there a way?
Fair point! Even with precausions I applied I experienced in the past cases wher due to some cloud service unavailability logger put something like 300k lines of errors into log within 24h! And then it becomes unmanageable to read and troubleshoot. But I do not think at the moment there is any build in functinality to achieve log limiting/rotation. Perhaps some 3rd party tools that could help, like externall script monitoring size of log and doing some magic…
There is an option to limit number of entries in the log file: max_entries
But this option does not work.
I created an issue on GitHub, so far no any movement there.
I agree this is a problem. I run my logs at info level as that provides enough data to troubleshoot most things after the fact. I’d like to be able to roll the log file over every day and keep N days.