Monitoring the logs after crash

HASSIO has been crashing every several days for me. The only way for me to get it back up is to restart the system. When that happens though HASSIO resets the logs.

Any suggestions on how to keep the logs even after a reboot? I believe this is a known issue.

1 Like

It does seem strange to wipe the logs from the SD card on reboot, if they get wiped then storing them RAM would be better IMO.

As a solution I can only suggest backing up the logs once per hour, with an automation maybe?

What do you think the best way would be to do this? Write a script? I don’t see a native way to copy a file with HASSIO.

Hello,

Does anyone have a script to do this? I’m having the same issue. My HA crashes every several days and I can’t find the issue source.

Yes, I used the one tom_l mentioned, but I needed to alter it a bit to get it to work. This one works for me:

configuration.yaml:

system_log:
  fire_event: true
  
notify:
  - name: persistent_log
    platform: file
    filename: persistent.log ### will be in /config

automations.yaml:

- id: my_system_log
  alias: My Persistent Error Log
  initial_state: true
  trigger:
    - platform: event
      event_type: system_log_event
      event_data:
        level: WARNING
    - platform: event
      event_type: system_log_event
      event_data:
        level: ERROR
  action:
    service: notify.persistent_log
    data_template:
      message: '{{ now().strftime("%H:%M %Y-%m-%d") }} {{ trigger.event.data.level }} [{{ trigger.event.data.name }}] {{ trigger.event.data.message[0] }} {{ trigger.event.data.exception }}'

Unfortunately my Pi crashes almost everyday and it did last night after I had this script running, but it did not catch any errors or warning prior to crashing :frowning:

2 Likes

Just a tip, when you see weird crashed and reboots without any error logs on a Pi. Check/Replace your USB-Power cable and maybe even charger. My cable was working fine mostly but apparently sometimes HA would just draw a bit too much power. It was driving me crazy, after replacing my cable everything is smooth now :slight_smile:

I know it’s been a while since your post but maybe you still have this problem or it might help someone else

3 Likes