I'm presently developing a credit card applicatoin according to flask. It runs fine breeding the server by hand using application.run(). I have attempted to operate it through mod_wsgi now. Oddly, I recieve a 500 error, and absolutely nothing within the logs. I have looked into a little and listed here are my findings.

  • Placing a line like print >>sys.stderr, "hello" works not surprisingly. The content turns up within the error log.
  • When calling a technique without needing a template it really works all right. No 500 Error.
  • Utilizing a simple template works fine too.
  • BUT the moment I trigger a database access inside web site (for instance looping on the query) I recieve the mistake.

My stomach informs me it's SQLAlchemy which produces a mistake, and perhaps some logging config causes the log to become thrown away at some stage in the applying.

Furthermore, for testing, I'm using SQLite. This, so far as I'm able to recall, are only able to be utilized in one thread. Therefore if mod_wsgi spawns more threads, it might break the application.

I'm a little baffled, since it only breaks running behind mod_wsgi, that also appears to swallow my errors. So what can I actually do to create the errors appear in to the apache error_log?

For reference, the code is visible about this github permalink.

Works out I wasn't drastically wrong. The exception was indeed tossed by sqlalchemy. So that as it's streamed to stdout automatically, mod_wsgi quietly overlooked it (so far as I will tell).

To reply to my primary question: How you can begin to see the errors created through the WSGI application?

It's really quite simple. Redirect your logs to stderr. The only real factor you must do, is add the next for your WSGI script:

import logging, sys

logging.basicConfig(stream=sys.stderr)

Now, this is actually the most mundane logging config. When I haven't put anything into position yet for my application this is going to do. But, I suppose, when the application matures you'll have a modern-day logging config anyways, which means this will not bite you.

However for fast and dirty debugging, this is going to do all right.