Adding detailed error logging to your live Apache2 WSGI application

authored by Frank Lynam at 08/02/2013 18:53:57

This is another fairly simple but by no means trivial note on how to go about debugging problems that you might be having with a WSGI application running in a live Apache2 environment.

WSGI logs errors to both your server’s and your virtual host’s error files but only if there is an adequate level of error logging enabled. If, like me, you are using virtual hosts then the following will show you how you enable this error logging.

Go to /etc/apache2/sites-available and open up the default file (or whichever configuration file is associated with your virtual host) using a text editor. Add in the following lines inside your VirtualHost tag (Make sure they are not already there and if they are, modify them to suit).


ErrorLog  ${APACHE_LOG_DIR}/error.log
LogLevel info
CustomLog  ${APACHE_LOG_DIR}/access.log combined

Save and exit the file and then restart your Apache2 server.

Upon encountering any HTTP 500 errors when accessing your WSGI application, you can now go to /var/log/apache2 and the error.log and access.log files should contain lots of useful information that will help diagnose any WSGI problems that you might be having.

Comments

submit