private object Formatter(HttpEventCollectorEventInfo eventInfo) { var settings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }; settings.Converters.Add(new StringEnumConverter()); return(JsonConvert.SerializeObject(eventInfo.Event.Data, settings)); }
// This is where the magic happens public CustomLogObject CustomFormatter(HttpEventCollectorEventInfo eventInfo) { var level = eventInfo.Event.GetType().GetProperty("Level").GetValue(eventInfo.Event, null); var renderedMessage = eventInfo.Event.GetType().GetProperty("RenderedMessage").GetValue(eventInfo.Event, null); var deserializedMessage = JsonConvert.DeserializeObject <RenderedMessage>(renderedMessage); var ret = new CustomLogObject { Level = level, RenderedMessage = deserializedMessage }; return(ret); }
public dynamic Formatter(HttpEventCollectorEventInfo info) { return(CustomFormatter(info)); }