-
-
Notifications
You must be signed in to change notification settings - Fork 46
Batch formatters
The batch formatter has the responsibility of batching a sequence of log events into a single payload that can be sent over the network. It does not care about individual log event formatting but instead focuses on how these events are serialized together into a single HTTP request.
The sink comes pre-loaded with two JSON based batch formatters where DefaultBatchFormatter is the default. You can decide to configure your sink to use any of these two, or write your own by implementing IBatchFormatter.
/// <summary>
/// Formats batches of log events into payloads that can be sent over the network.
/// </summary>
public interface IBatchFormatter
{
/// <summary>
/// Format the log events into a payload.
/// </summary>
/// <param name="logEvents">
/// The events to format.
/// </param>
/// <param name="formatter">
/// The formatter turning the log events into a textual representation.
/// </param>
/// <param name="output">
/// The payload to send over the network.
/// </param>
void Format(IEnumerable<LogEvent> logEvents, ITextFormatter formatter, TextWriter output);
/// <summary>
/// Format the log events into a payload.
/// </summary>
/// <param name="logEvents">
/// The events to format.
/// </param>
/// <param name="output">
/// The payload to send over the network.
/// </param>
void Format(IEnumerable<string> logEvents, TextWriter output);
}A sequence of log events are stored in a JSON object under a property called events. This formatter is inspired by the Seq sink.
{
"events": [
{ event n },
{ event n+1 }
]
}A sequence of log events are stored as a JSON array. This formatter is compatible with the Logstash HTTP input plugin configured to use the JSON codec.
[
{ event n },
{ event n+1 }
]