Move logfiles into subfolder config/logs

As the title says:
it would be very nice if the logs were moved to a /log sub folder in config.
It’s just more consistent and when using AppDeamon and there are some rotated logfiles it just gets much.
Currently this would include (afaik):

  • home-assistant.log
  • OZW_Log.txt
  • app_info.log
  • app_errors.log

You can specify the location of home-assistant.log with the --log-file parameter of hass.

You can specify the location of appdaemon log files in the appdaemon configuration

log:
  errorfile: /var/log/appdaemon/ha_apps_error.log
  logfile: /var/log/appdaemon/ha_apps.log

Thank you for the hint, I really did miss the log folders for AppDaemon.
Currently I am on HassIO, how would I set the parameter there?

I don’t use hassio, so I haven’t a clue.

yeh i agree - thought the same too and for the same reasons - in my case using hassio docker. i know it can be done externally but i think it’s better and more consistent through configuration yaml

how does one use --log-file with docker?

For anyone else looking to get this working in docker here’s the current solution

With homeassistant docker running run the following command
docker exec homeassistant cat /etc/services.d/home-assistant/run

Copy the output into a new file onto your host, edit it and add
--log-file=/tmp/hass.log
to the end of the exec python3 line

Then make sure you do
chmod +x file_path

Then when running your docker make sure and pass in
/file_path:/etc/services.d/home-assistant/run:ro

Annoyingly the fault log path doesnt change but i plan to put in a pr soon to fix that as well as get around having to do all that by using environment variables.

2 Likes

Is your solution compatible for those using docker-compose.yaml If so, any insight you can provide would be appreciated.

To be honest i forgot i had even done this (I think they changed the location of the file in the first command so i stopped using it)

But yeah this should work with compose, just add the final bit under your volumes: for home assistant

however the location of the file /etc/services.d/home-assistant/run no longer seems valid so it requires finding the new file location, which i do not currently know

I did work on a fix to the code base to allow use of an environment variable set in docker to set the log but i couldnt get a test environment running to test it so was unable to submit it to hass.