private static void FormatContent(LogEvent logEvent, TextWriter output) { if (logEvent == null) { throw new ArgumentNullException(nameof(logEvent)); } if (output == null) { throw new ArgumentNullException(nameof(output)); } output.Write('{'); CustomLogstashJsonFormatter.WritePropertyAndValue(output, "@timestamp", logEvent.Timestamp.ToString("o")); output.Write(","); CustomLogstashJsonFormatter.WritePropertyAndValue(output, "level", logEvent.Level.ToString()); output.Write(","); CustomLogstashJsonFormatter.WritePropertyAndValue(output, "message", logEvent.MessageTemplate.Render(logEvent.Properties)); if (logEvent.Exception != null) { output.Write(","); CustomLogstashJsonFormatter.WritePropertyAndValue(output, "exception", logEvent.Exception.ToString()); } CustomLogstashJsonFormatter.WriteProperties(logEvent.Properties, output); output.Write('}'); }
public void Format(LogEvent logEvent, TextWriter output) { CustomLogstashJsonFormatter.FormatContent(logEvent, output); output.WriteLine(); }