Improve exception logging