Adds logging when exception occurs