HABApp: Writing logs when running as a service

I am trying to investigate a problem, but I found that HABApp does not write any logs when running as a service. When started from the CLI, logs are written and also my custom messages appear. But it stops when I quit HABApp in the Terminal, only a final line is written into the logs:

 [WARN ] [HABApp.Rule                         ] - /usr/lib/python3.9/logging/handlers.py:1361: ResourceWarning:unclosed file <_io.TextIOWrapper name='/var/log/openhab/HABApp_events.log' mode='a' encoding='utf-8'>

OpenHAB logs everything without problems.
Am I missing some configuration?

HABApp 0.31.2 installation running on OpenHAB 3.2.0.

This looks like a permission problem to me. Are you sure your habapp process has access to /var/log/openhab.

I always run habapp as a service and never had any issue with logging.

1 Like

This message appears when habapp exits. Something with the log rotation in combination with the event logs buffer is not working correctly.

Stdout and stderr is empty? My first idea would be permission problem, too.

Thanks for the hint.
The user for the service defined in /etc/systemd/system/habapp.service was obenhab, but the correct user is openhabian.