views:

33

answers:

1

Hi

I'm working on a project that gets callbacks from some other sites' API. I expect my code to have a few errors, because I'm new to Python & Django. My site in development is using mod_wsgi and Apache with Debug = True ;)

The API I get the calls from adds a parameter to the querystring to my callback that is built using their own private key. So I have no way of accurately simulating that. If my code fails once I activate my probably faulty key validation code, I have no way of knowing except for apache server logs (which don't show the actual stacktrace or anything).

How can I log a more detailed python exception, like the one I usually see in my browser every 2 minutes ;) to a file? Especially the local variables around the faulty line are interesting obviously :)

Thanks! :)

+2  A: 

If you set ADMINS in your settings.py (and set DEBUG=False) you will be emailed all 500 server errors (just like the DEBUG error page).

However, if you want your app to continue without responding with a 500, you can import logging and write your own debug log. There's a good tutorial here:

http://simonwillison.net/2008/May/22/debugging/

jturnbull
Wow, that was quick. Great tutorial for some newby python logging and debugging, thanks. The logging to file section was great, since I don't want to have to figure out where mod_python and apache would be putting my print statements' output. Thanks!
rdrey