Ejemplo n.º 1
0
 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('}');
 }