views:

448

answers:

3

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!

+1  A: 

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.

Alex JL
Thanks for the response. I have read the Apache error log, but the information is not very valuable. Yes, this is a production environment so I'd prefer not to turn DEBUG on.The tough part is that I am not seeing the errors, but customers randomly are. So I am trying to retroactively diagnose. My dream would be to see a Python stack trace in an error log somewhere.
Andrew C
I know what you mean, I have all my errors logged for PHP like that but I'm not sure how to get it going with Django. I need to know also, actually. diegueus9's response leads to some good info.
Alex JL
A: 

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.

Peter Rowell
+1  A: 

This can help you http://stackoverflow.com/questions/1925898

diegueus9