Log all exceptions

Uses a middleware to capture exceptions and log them.  This is useful
for serving images and ajax calls, where the text of 500 errors
are not displayed.
Merge branch 'master' into log_all_exceptions
Fixed whitespace.
Move middleware setting, improve exception message.
Removed unused import
Merge pull request #954 from andrewbaxter/log_all_exceptions

Log all exceptions