Add logging middleware to log exceptions in views.