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.
It's used both by Django's development server and in production WSGI deployments. WSGI servers obtain the path to the application callable from their configuration. Django's built-in server, namely the runserver command, reads it from the WSGI_APPLICATION setting. By default, it's set to <project_name>.
The WSGIScriptAlias directive behaves in the same manner as the Alias directive, except that it additionally marks the target directory as containing WSGI scripts, or marks the specific file-path as a script, that should be processed by mod_wsgi's wsgi-script handler.
WSGI is a specification of a generic API for mapping between an underlying web server and a Python web application.
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 logging
module 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With