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?

1 Answer 1

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.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.