private static FormattedException FormatException(LoggableException exception) { var message = new FormattedException { Message = exception.Message, EnvironmentStackTrace = Environment.StackTrace, Source = exception.Source, StackTrace = exception.StackTrace, TargetSite = exception.TargetSite.IfNotNull(x => x.ToString()) }; if (exception.InnerException != null) { message.InnerException = FormatException(exception.InnerException); } return(message); }
private static void AppendException(XmlDocument document, XmlElement element, FormattedException exception) { var exceptionElement = document.CreateElement("InnerException"); Append(exceptionElement, "Message", exception.Message); Append(exceptionElement, "Source", exception.Source); Append(exceptionElement, "StackTrace", exception.StackTrace); Append(exceptionElement, "TargetSite", exception.TargetSite); if (exception.InnerException != null) { AppendException(document, exceptionElement, exception.InnerException); } Append(exceptionElement, "EnvironmentStackTrace", Environment.StackTrace); element.AppendChild(exceptionElement); }