Is the syslog platform functional in 0.86.3?

I am unable to use the syslog platform to write a message to the system log in 0.86.3.

My configuration.yaml file contains the following on both my production and test systems:

notify:
  - name: loginfo
    platform: syslog

On my production system running 0.80 in a venv:

  • Used the Services page to execute notify.loginfo with {"message": "TEST TEST TEST"}
  • The message appears in the system log: Jan 28 12:43:23 ha_server Home Assistant[587]: TEST TEST TEST

On my test system running 0.86.3 in a docker container:

  • Used the Services page to execute notify.loginfo with {"message": "TEST TEST TEST"}
  • The message does not appear in the system log (I am using Portainer to view the Home Assistant container’s system log).

Is the message’s failure to appear in the log due to a bug in 0.86.3 or (because I’m a docker neophyte) is it somehow related to it running in a docker container?

Yes. The container is a dedicated process runtime environment and shares nothing but the Kernel with the host system. So the syslog daemon is local to the container and output to STDOUT, because that’s what containers are supposed to do.

Doesn’t the syslog platform write to the system log within the container? That’s the system log I’m viewing (with Portainer).

After all, Home Assistant does successfully write its other messages to the system log in its container.

I’ve done some ‘light reading’ and made a few experiments but the results I get still baffle me.

I directed Home Assistant’s container to use syslog for logging (instead of the default json-file driver). Now when Home Assistant starts up, its log messages are directed to the syslog server running on the host machine (testsys, 192.168.1.99).

Here’s the relevant portion of docker-compose.yaml. Note the logging option.

version: '3'
services:
  homeassistant:
    container_name: homeassistant
    image: homeassistant/home-assistant:0.86.3
    network_mode: "host"
    volumes:
      - /home/testsys/docker/homeassistant:/config
      - /etc/localtime:/etc/localtime:ro
    restart: unless-stopped
    logging:
      driver: syslog
      options:
        syslog-address: "udp://192.168.1.99:514"
        syslog-facility: daemon
        tag: HASS

Here’s a portion of the messages produced by the Home Assistant container and logged on the host machine (testsys). I viewed this on testsys using tail -100 /var/log/syslog.

Jan 28 21:55:16 testsys.local HASS[1405]: 2019-01-28 21:55:16 INFO (MainThread) [homeassistant.components.notify] Setting up notify.syslog
Jan 28 21:55:16 testsys.local HASS[1405]: 2019-01-28 21:55:16 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.template
Jan 28 21:55:16 testsys.local HASS[1405]: 2019-01-28 21:55:16 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.systemmonitor
Jan 28 21:55:16 testsys.local HASS[1405]: 2019-01-28 21:55:16 INFO (MainThread) [homeassistant.setup] Setting up logbook
Jan 28 21:55:16 testsys.local HASS[1405]: 2019-01-28 21:55:16 INFO (MainThread) [homeassistant.setup] Setup of domain logbook took 0.0 seconds.
Jan 28 21:55:16 testsys.local HASS[1405]: 2019-01-28 21:55:16 INFO (MainThread) [homeassistant.setup] Setting up conversation

I do believe this confirms the container’s log messages are successfully directed to the host machine’s syslog.

Nevertheless, when I use Home Assistant’s syslog platform, its messages fail to appear in the log.

Can someone explain, in detail, why Home Assistant’s log messages are coming through but not the ones created by the syslog platform?

UPDATE

I’ve concluded the syslog notification platform simply does not work when Home Assistant is dockerized. I don’t believe the issue is limited to version 0.86.3. I randomly selected version 0.84.6 and it didn’t work there either. In contrast, Home Assistant’s core system, and most every other component, successfully writes to the system log.

I’ve looked through the source code and it seems everything that successfully writes to the system log uses python’s logging module. In contrast, the syslog notification platform uses python’s syslog module. Just a wild guess but maybe this library is flawed or missing from Home Assistant’s docker image (or something else that renders it unable to complete its intended purpose).

As a workaround, I’m using system_log.write because it works from a Home Assistant container. I think the next step is for me to post this as an issue in Github.

1 Like