Improve logging in exceptions