Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you trace 500 server errors with Apache + mod_python + Django? [duplicate]

Tags:

Possible Duplicate:
Django Unhandled Exception

I'm randomly getting 500 server errors and trying to diagnose the problem. The setup is:

Apache + mod_python + Django

My 500.html page is being served by Django, but I have no clue what is causing the error. My Apache access.log and error.log files don't contain any valuable debugging info, besides showing the request returned a 500.

Is there a mod_python or general python error log somewhere (Ubuntu server)?

Thanks!

like image 891
Andrew C Avatar asked Jan 10 '10 05:01

Andrew C


2 Answers

Yes, you should have an entry in your apache confs as to where the error log is for the virtual server. For instance the name of my virtual server is djangoserver, and in my /etc/apache2/sites-enabled/djangoserver file is the line

ErrorLog /var/log/apache2/djangoserver-errors.log

Although now that I reread your question, it appears you already have the apache log taken care of. I don't believe there is any separate log for mod_python or python itself.

Is this a production set up?

If not you might wish to turn on Debug mode, and then Django produces very detailed screens with the error information. In your project's settings.py, set

DEBUG = True
TEMPLATE_DEBUG = DEBUG

to disable the generic 500 error screens and see the detailed breakdown.

like image 158
JAL Avatar answered Oct 13 '22 08:10

JAL


Salsa makes several good suggestions. I would add that the Django development server is an excellent environment for tracking these things down. Sometimes I even run it from the production directory (gasp!) with ./manage.py runserver 0.0.0.0:8000 so I know I'm running the same code.

Admittedly sometimes something will fail under Apache and not under the dev server, but that is a hint in and of itself.

like image 41
Peter Rowell Avatar answered Oct 13 '22 08:10

Peter Rowell