Easy application logging/debugging with nginx, uwsgi, flask? Easy application logging/debugging with nginx, uwsgi, flask? nginx nginx

Easy application logging/debugging with nginx, uwsgi, flask?


Set config['PROPAGATE_EXCEPTIONS'] to True when running app in production and you want tracebacks to be logged into log files. (I haven't tried with SMTP handler, though..)


  1. The part where you create handlers, add to loggers etc. should be in the if __name__ == '__main__' clause, i.e. your main entry point. I assume that would be run.py.
  2. I'm not sure I can answer this - it depends on what you want. I'd advise looking at the logging tutorial to see the various options available.
  3. I don't believe you need to change anything at the nginx level.

Update: You might want to have an exception clause that covers uncaught exceptions, e.g.

if __name__ == '__main__':    try:        app.run(debug=True)    except Exception:        app.logger.exception('Failed')

which should write the traceback of any exception which occurred in app.run() to the log.


I know that this is a VERY old post, but I ran into the issue now, and it took me a bit to find the solution. Flask sends errors to the server. I was running Gunicorn with an upstart script on Ubuntu 14.04 LTS, and the place where I found the error logs was as follows:

/var/log/upstart/myapp.log

http://docs.gunicorn.org/en/stable/deploy.html#upstart

Just in case some other poor soul ends up in this situation.