I've created a Flask app, throughout which I create loggers in each module with the line LOGGER = logging.getLogger(__name__)
. In the app's main module is
if __name__ == '__main__':
app.run(host='0.0.0.0', port=9876)
# subprocess.call(['gunicorn', 'main:app', '-w', '5', '-b', '0.0.0.0:9876'])
The two lines under the if
are alternatively commented and uncommented whether I choose to run through gunicorn or not. When not running through gunicorn, a request to an endpoint will result in logs being printed. For example:
07-23 10:38 - INFO - 127.0.0.1 - - [23/Jul/2018 10:38:49] "POST /path/to-endpoint HTTP/1.1" 200 -
But when run through gunicorn, no such logs are printed (though the expected results of the request are returned.
This question is similar to the one posed here, but the scenario is different enough that the proposed fix does not help.
Any ideas?