How to automatically purge home assistant log?

If you are sure about it, is good

What is an “entry”, are the below 4 entries?

2019-06-01 19:14:50 ERROR (MainThread) [homeassistant.components.automation] Error while executing automation automation.automation_ran. Service not found for call_service at pos 2: (ServiceNotFound(...), 'Service notify.filed_automations not found')

2019-06-01 19:14:50 ERROR (MainThread) [homeassistant.components.automation] Error while executing automation automation.automation_ran. Service not found for call_service at pos 2: (ServiceNotFound(...), 'Service notify.filed_automations not found')

2019-06-01 19:14:55 ERROR (SyncWorker_15) [homeassistant.components.opengarage.cover] Unable to connect to OpenGarage device: HTTPConnectionPool(host='192.168.1.171', port=80): Max retries exceeded with url: /jc (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7ff73a0ddf28>: Failed to establish a new connection: [Errno 113] Host is unreachable'))

2019-06-01 19:15:00 ERROR (MainThread) [homeassistant.components.automation] Error while executing automation automation.sensor_values_to_file. Unknown error for call_service at pos 1:

Because I have 5000+ of those after 5 hours from deleting the log and restart (now 4Mb big). My configuration is now

system_log: 
   max_entries: 500

so far seems same behaviour as when I hadn’t system_log in my configuration file

The system_log has nothing to do with the home-assistant.log, it’s just some extention to see some (unwanted for me) log entries on the info page.
If you want to tune the log, take a look here, but there’s nothing about the size and purging.

Oh, I see.

Well I thought the title was clear: yes I am talking about the file home-assistant.log which becomes too big, and wish to control its size in an automatic way

1 Like

Believe me, there are situations when you’re happy that you have an older log entry.
If you’re NOT on hassio, you can start HA with log rotate.

hass --log-rotate-days 4

In my case, I have no logger entry in configuration.yaml. Nevertheless, there is a home-assistant.log file and it’s about 82 Kb. Whatever I see in there is also found in /var/log/syslog.

The home-assistant.log file is automatically purged after every restart whereas the duplicated entries in syslog are retained.

Anyway, that’s how it works on my system (version 0.89 in a venv).

Unfortunately I am on HASSIO, now the log is 10Mb (was 3MB) this afternoon), I really do not care about its content, just wish to max its size automatically

I’m still don’t get why you want to have its size set to max if you don’t care about the file?
Hass.io relies on SD card writes so imho it’s logical to keep HA’s log file to a min.

Probably the easiest way of doing this is with the shell command service

Then you’d have to make a shell command that checks the size of HA log, then wipes it if it’s over a certain size. If you’re OK with linux commands this shouldn’t be too hard.

Finally you can set an automation in HA to run the command once per hour for example.

Good luck :slight_smile:

EDIT: It would be nice if you could set the ‘logger’ component to have a max number of entries, something similar to ‘logrotate’

1 Like

It seems like missing functionality to not be able to manually purge the HA logs. Or at least a good feature to add.

In my case I created a huge amount of HA logs while debugging and setting up a couple of scripts and automations. Firstly it is a pain to scroll down to the bottom of the file each time I want to see what went wrong. And now that I’m done, I want to get rid of all the crap, clear the logs and start fresh.

Sure I can write a script to truncate the file in Linux, but for the same reason someone decided it’s valid to expose a service to clear the system logs, they can also create/expose a service to clear the HA logs.

2 Likes

I had nothing in my configuration and when I inspect the log it is actually more than 50 (rather thousands!) and reality beats documentation by far. Not having anything obviously results in more than 50 log items, no matter what the documentation says. It will fill your SD card no matter what the documentation says.

It must have been very important to you to take the time to comment on a post made 2 years ago. Perhaps that time would be better spent correcting your error-ridden system and/or posting an Issue in the Github Core repo. Good luck.

and you, one may think that after 2 years you would improve your bad manners. 2 years lost, you are worse then ever

8 Likes

No soup for you!

I don’t have a problem with this at the moment as i have 50+ GB of space on my instance. I just wanted to let people finding this (as I did, when searching for things related to ever growing disk usage of Home Assistant) that it is in fact not as in the documentation.

This error log (having a “max_entries” with non-working default) is not my problem, though, as it only takes around 10mb of storage anyway (even though there is 1000+ entries). Something else is eating 100mb/day, and I will not post an issue until I find it.

I did not mean to offend you. Even if the post is 2+ years old it is still the same documentation and it is still not accurate so my post is still relevant today.

4 Likes

If you believe it doesn’t behave as documented, report it as an Issue in Home Assistant’s GitHub Core repository.

If the development team agrees with you, perhaps they will correct it.

I don’t believe; I know. My current setup does not specify a max_entries and it contains 217 entries.

As I stated previous; I will not post an issue as this is not my main issue. And as this is not my main issue posting additional replies in this tread is likewise not what I will spend more time doing. Have a nice day :slight_smile:

1 Like

It’s not my main issue either (largely because my two systems have never logged so many errors).

I agree that continuing to discuss it here isn’t worthwhile. Only by reporting it as an Issue is it likely to change anything.

Not to interrupt a good argument, but a Hitron Cable modem that was automatically found by UPnP and that I set up because I wanted to see if it had any useful sensors created error after error and eventually crashed Home Assistant by filling the SSD with a 25GB (yes, GB) log file with thousands of instances of the same error message…so clearly there is no auto-limitation to log file size…

You appear to skimmed over VDRainer’s explanation posted over 2 years ago.