Improve the LogException method