Log file that isn't erased

Regularly, in the middle of the night, my Raspberry hangs.
No automation is done anymore. But a ping to the PI is still OK.
I have to do a power-off of my PI. And each time the log file is cleared.
So I have no idea what the problem could be. Isn’t it possible to keep the log file for some days?

Environment:
My Raspberry Model 4 is about 2 months old. I have the lastest versions of Host, supervisor.
I’m relatively new so I use only a limited number of integrations. My automation is done with Node-red.
My PI uses less than 10% disk and RAM. CPU usage is about 1%

Don’t forget to vote for your request.
I think that would be very usefull.

Until then,

If you are able to SSH to HA, you can try to copy the log with:

cp /config/home-assistant.log /config/home-assistant_$(date +%Y%d%m%H%M%S).log

For normal restarts you can also use a shell_command:

shell_command:
  copy_log: "cp /config/home-assistant.log /config/home-assistant_$(date +%Y%d%m%H%M%S).log"

and an automation:

- id: '1611002623040'
  alias: Copy log on restart
  description: ''
  trigger:
  - platform: homeassistant
    event: shutdown
  condition: []
  action:
  - service: shell_command.copy_log
    data: {}
  mode: single

Don’t forget to delete old logs from time to time and activate the automation only for debugging. :slightly_smiling_face: