Logging stdout to gunicorn access log?

flask, gunicorn

Solution

Use the logging: set the stream to stdout

import logging

app.logger.addHandler(logging.StreamHandler(sys.stdout))
app.logger.setLevel(logging.DEBUG)

app.logger.debug("Hello World")

Problem

When I wrap my Flask application in gunicorn writing to stdout no longer seems to go anywhere (simple `print` statements don't appear). Is there someway to either capture the stdout into the gunicorn access log, or get a handle to the access log and write to it directly?

Original source