supervisord logs don't show my output supervisord logs don't show my output python python

supervisord logs don't show my output


Python output is buffered. Setting the environment variable PYTHONUNBUFFERED=1 in you supervisord.conf will disable buffering and show log messages sooner:

[program:x]environment = PYTHONUNBUFFERED=1

or add the -u command-line switch to python command:

[program:x]command = python -u file.py

Alternatively you can flush the sys.stdout handler explicitly:

sys.stdout.flush()

On python 3.3 and up, you can add the flush=True parameter to have the function do this for you:

print(something, flush=True)


You can run your program like this:

python -u file.py

this will produce unbuffered output


If you have python based script that you can't or don't want to change to flush output on a regular base then you can use unbuffer from the Expect package.

For a Django application in a docker container I've lately used it like that (from a shell script run from supervisord):

unbuffer python -u manage.py runserver 0.0.0.0:11000 2>&1 >> /var/log/django.log