SkillAgentSearch skills...

Serilog.Sinks.Humio

Serilog sink for Humio

Install / Use

/learn @ThomasWillumsen/Serilog.Sinks.Humio
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Serilog.Sinks.Humio

A Serilog sink that writes events in periodic batches to Humio.

Package - Serilog.Sinks.Humio
Platforms - .NET Standard 2.0

The sink takes care of formatting Serilog's structured logs and sending them to Humio using the structured approach in Humio's Ingest API.

<br/>

Configuration

Simple

var log = new LoggerConfiguration()
    .WriteTo.HumioSink("{token}") // ingest token is acquired from Humio cloud
    .CreateLogger();
<br/>

Advanced configuration

var log = new LoggerConfiguration()
    .WriteTo.HumioSink(new HumioSinkConfiguration
    {
        IngestToken = "{token}",
        BatchSizeLimit = 50,
        Period = TimeSpan.FromSeconds(5),
        // Can be used for an on-premises hosted solution.
        // If you are using Humio Community edition the url must be set to https://cloud.community.humio.com
        Url = "https://myOnPremHumio.com",
        Tags = new KeyValuePair<string, string>[]{
            new KeyValuePair<string, string>("host", "{my_host}"),
            new KeyValuePair<string, string>("source", "{my_application}"),
            new KeyValuePair<string, string>("tag3", "some value"),
            new KeyValuePair<string, string>("tag4", "some value"),
            // ...
        }
        RestrictedToMinimumLevel = Serilog.Events.LogEventLevel.Warning
    })
    .CreateLogger();
<br/>

Using Serilog.Settings.Configuration

var log = new LoggerConfiguration()
    .ReadFrom.Configuration(configuration)
    .CreateLogger();

Appsettings.json

{
  "Serilog": {
    "Using": ["Serilog.Sinks.Humio"],
    "MinimumLevel": {
      "Default": "Verbose",
      "Override": {
        "Microsoft": "Verbose",
        "Microsoft.Hosting.Lifetime": "Verbose"
      }
    },
    "WriteTo": [
      {
        "Name": "HumioSink",
        "Args": {
          "IngestToken": "{token}",
          "Url": "https://cloud.community.humio.com"
        }
      }
    ]
  }
}

Newtonsoft.Json has been replaced in 2.0.0

The sink now uses System.Text.Json instead of Newtonsoft.Json for serializing the log events. This is to reduce the number of third-party dependencies and to improve performance. The last version of the sink that uses Newtonsoft.Json is 1.1.4. There are no plans to support Newtonsoft.Json in the future.

Related Skills

View on GitHub
GitHub Stars6
CategoryDevelopment
Updated7mo ago
Forks5

Languages

C#

Security Score

77/100

Audited on Sep 2, 2025

No findings