I'm having a systemd service defined as follows, that works fine:
[Unit]
Description=my service
After=network.target
[Service]
User=myuser
Group=mygroup
WorkingDirectory=/home/myuser/myapp
Environment="PATH=/home/myuser/myapp/.venv/bin"
ExecStart=/home/myuser/myapp/.venv/bin/python3 /home/myuser/myapp/run.py
Restart=on-failure
[Install]
WantedBy=multi-user.target
This is a Python web application based on Flask framework. Normally in the stdout of the application I can see incoming requests "live", I mean when I run the app like python run.py.
Now after starting the service I'd like to follow logs of the app and I do:
sudo journalctl -f -u my_app.service
and incoming logs are awfully slow - sometimes it takes minutes or more for them to appear in logs. Afterwards they all have proper timestamp though, so it's not like they're disappearing, they do, but after a long time.
What I've tried:
to redirect systemd service output to files:
StandardOutput=file:/var/log/my_app/output.logStandardError=file:/var/log/my_app/error.logwith no luck - they save fine but with the same slow speed
to try to dump journalctl logs to offline faster setting
SyncIntervalSecfrom default5mto5s- didn't help either
Is there any way to pass those logs faster from my application to journald? I don't have troubles with other services like system authentication ones - I see records immediately.
My journald.conf file has default parameters (except one above), my systemd is version 237 and I'm running Ubuntu 18.04.