Add stack traces to log when exceptions occur