Add logging for exceptions