0

I have a Flask app running on nginx + uWSGI.

On my local server (non-nginx), I get a nice stack trace + error reporting for exceptions.

Like this:

$ python run.py 
Traceback (most recent call last):
  File "run.py", line 1, in <module>
    from myappname import app
  File "/home/me/myappname/myappname/__init__.py", line 27, in <module>
    file_handler.setLevel(logging.debug)
  File "/usr/lib/python2.7/logging/__init__.py", line 710, in setLevel
    self.level = _checkLevel(level)
  File "/usr/lib/python2.7/logging/__init__.py", line 190, in _checkLevel
    raise TypeError("Level not an integer or a valid string: %r" % level)

On nginx, there is next to no logging whatsoever (in /var/log/nginx/error.log).

This post suggests adding app.logger.exception('Failed') to my script, which didn't help.

How do I enable this sort of logging for debugging purposes?

Community
  • 1
  • 1
okoboko
  • 4,332
  • 8
  • 40
  • 67

1 Answers1

1

Nginx will capture your app's console output, but you must make the app recover from exceptions. Else, you'll only get 500 or 400 errors from Nginx.

  1. Try running the app off Nginx until it seems stable.
  2. Use the logging module to capture app status information to your own log file. This strategy will be useful in the long run.
Apalala
  • 9,017
  • 3
  • 30
  • 48