python - Flask is not printing sys.stdout.write messages -


i running flask app link using command python app.py.

more logs printed using, sys.stdout.write not printed on console. using logging.streamhandler works redirecting messages stdout.

it works,

import logging import logging.handlers logger = logging.getlogger('kumologging') logger.setlevel(logging.debug) ch = logging.streamhandler() logger.addhandler(ch) logger.info("hey, logger obj") 

it doesn't work

import sys sys.stdout.write("hey, stdout") 

does flask override sys.stdout file descriptor, redirecting logs elsewhere?

afaik flasks app.run() uses gunicorn web package

i believe gunicorn 1 redirecting output

the output might in /var/log/gunicorn/error.log (not sure on windows :/)

or possible sys.stdout not flushing buffer, try sys.stdout.flush() after writting it


Comments