I’m quite new using home assistant so I’m sorry if this is a beginner question. Does anyone know how to disable file logs?
I’m running the home assistant in my kubernetes and I really don’t need the files.
I’m quite new using home assistant so I’m sorry if this is a beginner question. Does anyone know how to disable file logs?
I’m running the home assistant in my kubernetes and I really don’t need the files.
Unfortunately there is no way to do this right now. There is a feature request for it so you can add yourself to that.
Even for non-kubernetes users this file is mostly superfluous. In HAOS or supervised installs its a requirement to use journal logging so everything is in the systemd-journal. And container users generally have their own logging strategy (like yours). The only ones who might actually need it are users on a core install so I guess it would be nice to leave an option for them.
EDIT: Actually I guess that FR I linked has a creative workaround in the comments so you could try that, haven’t tried it myself:
Thanks Mike, it works.
I was expecting something I could add to my configuration so I could easily rebuild my environment in case of disaster.
Dropped my upvote there
Just FYI for those who ended up here. This solution doesn’t work if you are using kubernetes
I’m migrating my HA instance into kubernetes and ran into this problem too. I ended up with a different workaround, so I’ll leave this here for others:
TL;DR There’s a slightly hacky way to disable logging to disk in the core
container, but you’ll have to build your own wrapper image.
I found that HA will skip logging to disk if the log file path isn’t accessible, so I took advantage. I’m now passing --log-file /non-existant-path/home-assistant.log
at startup. HA prints an error about the bad path, but otherwise runs normally, as far as I can tell, without logging to disk.
Unfortunately the HA core container doesn’t provide a way to pass custom command line options, so this also requires building a wrapper container. That’s a bit of a hassle if you aren’t set up for it, but for those who are, here’s my entire Dockerfile:
ARG IMAGE_TAG=2023.12.4
FROM homeassistant/home-assistant:${IMAGE_TAG}
# disable logging to disk
RUN sed -i 's|--config|--log-file /non-existant-path/home-assistant.log --config|' /etc/services.d/home-assistant/run
Partial startup logs (showing the the “access denied” error, which can be ignored):
...
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
services-up: info: copying legacy longrun home-assistant (no readiness notification)
s6-rc: info: service legacy-services successfully started
2024-01-01 12:22:38.728 ERROR (MainThread) [homeassistant.bootstrap] Unable to set up error log /non-existant-path/home-assistant.log (access denied)
2024-01-01 12:22:38.729 INFO (MainThread) [homeassistant.bootstrap] Config directory: /config
2024-01-01 12:22:38.791 INFO (SyncWorker_0) [homeassistant.loader] Loaded homeassistant from homeassistant.components.homeassistant
2024-01-01 12:22:38.792 INFO (SyncWorker_3) [homeassistant.loader] Loaded persistent_notification from homeassistant.components.persistent_notification
2024-01-01 12:22:38.800 INFO (MainThread) [homeassistant.setup] Setting up homeassistant
...
I’ve been running this way in kubernetes for a few days now, and haven’t noticed any issues.
Why wouldn’t you simply:
logger:
default: critical
You definitely want to know about critical warnings.
I want logs, I just don’t want them on disk. HA also writes logs to stderr/stdout, and that’s what Kubernetes expects – there’s first-class support for viewing/collecting stderr/stdout logs. The file on disk is redundant, and eats up space on the container filesystem.
I ended up setting --log-file /config/logs/home-assistant.log
and then mounting in a emptyDir
to /config/logs
to get around this. The logs still get written but are deleted upon container restart.
Hi,
I got the same issue here.
On my side the workaround found is to redirect /config/home-assistant.log to /dev/null in the docker compose:
volumes:
- /dev/null:/config/home-assistant.log
The file will be present on the disk but will stay empty (That’s what I was looking for)