protected override string GetFormattedMessage(LogEventInfo logEvent) { if (logEvent is VirastyarLogEventInfo) { var serializer = new YAXSerializer(logEvent.GetType()); try { return(serializer.Serialize(logEvent)); } catch (Exception ex) { Debug.WriteLine(ex.ToString()); return("Error in serialization: " + Environment.NewLine + ex); } } return("Unexpected log class"); }
/// <summary> /// Initializes a new instance of the <see cref="LogDetailsViewModel"/> class /// </summary> /// <param name="log">The <see cref="LogEventInfo"/> to display</param> public LogDetailsViewModel(LogEventInfo log) { this.DetailRows = new ReactiveList <LogDetailsRowViewModel>(); foreach (var propertyInfo in log.GetType().GetProperties()) { var propertyName = propertyInfo.Name; var content = propertyInfo.GetValue(log) ?? string.Empty; var row = new LogDetailsRowViewModel { Property = propertyName, Content = content.ToString() }; this.DetailRows.Add(row); } }