Logger.WriteException function to write exceptions in a consistent format