Skip to content

A Serilog sink that periodically sends log events formatted as JSON to http input plugin of the Fluentd service using POST method.

License

Notifications You must be signed in to change notification settings

Georgy-Losenkov/serilog-sinks-fluentd-http-json

Repository files navigation

Serilog.Sinks.Fluentd.Http.Json verify Nuget

Table of contents

What is this sink

The Serilog Fluentd Http Json sink project is a sink (basically a writer) for the Serilog logging framework. Structured log events are written to sinks and each sink is responsible for writing it to its own backend, database, store etc. This sink delivers the data to the http endpoint of the Fluentd daemon in json format. By default it uses Serilog.Formatting.ElasticSearch json formatter, making it suitable for forwarding to ElasticSearch.

Features

  • Simple configuration to get log events published to Fluentd daemon. Only endpoint url is needed.
  • Log events are accumulated in the memory and periodically are sent in batches LoPeriodic batching

Quick start

Install the Serilog.Sinks.Fluentd.Http.Json package from NuGet:

Install-Package Serilog.Sinks.Fluentd.Http.Json

To configure the sink in C# code, call WriteTo.Fluentd() during logger configuration:

var log = new LoggerConfiguration()
    .WriteTo.Fluentd()
    .CreateLogger();

To configure the sink through configuration file using Serilog.Settings.Configuration, just add { "Name": "Fluentd" } into "WriteTo" section:

"WriteTo": [
  ...
  { "Name": "Fluentd" }
]

Parameters

public static LoggerConfiguration Fluentd(
    this LoggerSinkConfiguration sinkConfiguration,
    Int32 bodySizeLimit = 32 * 1024 * 1024,
    TimeSpan? flushPeriod = null,
    TimeSpan? httpTimeout = null,
    Int32? maxQueueSize = 10000,
    ITextFormatter jsonFormatter = null,
    String url = "http://localhost:8888/logging.log")

bodySizeLimit

The size limit of the json sent to fluentd. Default value is 32Mb (33554432 bytes). This corresponds to default value of parameter body_size_limit of fluentd http input plugin.

flushPeriod

Interval between communication sessions with fluentd. Default value is null value. That corresponds to 4 sec.
When sink is being disposed this value is used as timeout for sending remaining log events to fluentd.

httpTimeout

Time to wait for submitting to complete. Default value is null value. That corresponds to 3 sec.

maxQueueSize

Maximum size of the queue accumulating log events. Default value is 10000. Null value means no limits.

jsonFormatter

The JSON formatter. By default Serilog.Formatting.ElasticSearch formatter is used.

url

The URL of the fluentd http input endpoint appended by the tag name.
Because of limitaions of the fluentd http input plugin tag must contain period, e.g logging.log.

About

A Serilog sink that periodically sends log events formatted as JSON to http input plugin of the Fluentd service using POST method.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages