Log a thrown exception properly with backtrace