Improved exception logging.