I’ve developed this Python script that uses the logging module to log output. The idea is that it is supposed to output to stdout as well as to a log file.
I start with a basic config by setting the logging level and format:
The script runs an infinite while loop (e.g. ‘while True:’) until terminated.
When I run this from an active console, it works exactly as anticipated. But if I run it as a systemd service, I get nothing for output. The log file never records anything, and journald never captures any of the standard output.
On the systemd side, I’m running the script as a “simple” service. I’m not using any special parameters for logging. In the past this has worked for me, so I’m not sure why it doesn’t work now. I am running it on Debian 11. I’ve looked through the docs for both python’s logging module and systemd, but a lot of what I’m reading doesn’t seem to answer my question.
Any thoughts, ideas or other suggestions? I’m happy to share more code if that helps.