Proper logging for exceptions