I’m getting started with developing Django code on a server, running on top of Apache/mod_wsgi.
I’m looking to understand a few things:
-
What techniques are normally used to
debug applications running on the
server? -
Specifically, I’m trying to just use
"print" debugging for now. But I
can’t seem to get print statements
to work. I’m printing to stderr, but
I’m not sure which log file I should
be looking at. According to
this, I should be using
environ['wsgi.errors'], but how do
I access that from my Django code?
Thanks!
EDIT: By the way, adding the line print >> sys.stderr, 'message ...' not only doesn’t seem to print to any log file, it causes parts of my application to simply not load.
Try using the django debug toolbar. It can help a great deal with debugging when you can’t actually use a debugger.
Really though, debugging should be done on your development machine. I have yet to see a code issue in production with django that wasn’t also occurring on my dev box.
You usually can’t print in mod_wsgi. Use the
loggingmodule instead. That’s really what you want, and the debug toolbar will show you log statements in the page, so you don’t even have to look at the file.