Athena.Serilog.Sinks.ZincSearch 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Athena.Serilog.Sinks.ZincSearch --version 1.0.1                
NuGet\Install-Package Athena.Serilog.Sinks.ZincSearch -Version 1.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Athena.Serilog.Sinks.ZincSearch" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Athena.Serilog.Sinks.ZincSearch --version 1.0.1                
#r "nuget: Athena.Serilog.Sinks.ZincSearch, 1.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Athena.Serilog.Sinks.ZincSearch as a Cake Addin
#addin nuget:?package=Athena.Serilog.Sinks.ZincSearch&version=1.0.1

// Install Athena.Serilog.Sinks.ZincSearch as a Cake Tool
#tool nuget:?package=Athena.Serilog.Sinks.ZincSearch&version=1.0.1                

Athena.Serilog.Sinks.ZincSearch

ZincSearch Sink for Serilog

https://zincsearch-docs.zinc.dev/

Quickstart

The Athena.Serilog.Sinks.ZincSearch NuGet package could be found here. Alternatively you can install it via one of the following commands below:

NuGet command:

Install-Package Athena.Serilog.Sinks.ZincSearch

.NET Core CLI:

dotnet add package Athena.Serilog.Sinks.ZincSearch

In the following example, the sink will send log events to ZincSearch available on http://localhost:4080

ILogger logger = new LoggerConfiguration()
    .WriteTo.ZincSearch(
        "http://localhost:4080"
         index: "zincsearch_test",
         credentials: new ZincSearchCredentials{
            Username = "admin",
            Password = "123456"
         }
    )
    .CreateLogger();

logger.Information("The god of the day is {@God}", odin)

Used in conjunction with Serilog.Settings.Configuration the same sink can be configured in the following way:

{
  "Serilog": {
    "Using": ["Athena.Serilog.Sinks.ZincSearch"],
    "MinimumLevel": {
      "Default": "Debug"
    },
    "WriteTo": [
      {
        "Name": "ZincSearch",
        "Args": {
          "uri": "http://localhost:4080",
          "index": "zincsearch_test",
          "credentials": {
            "username": "admin",
            "password": "123456"
          },
          "rollingInterval": "Month"
        }
      }
    ]
  }
}

Description of parameters and configuration details could be found here.

Custom HTTP Client

Athena.Serilog.Sinks.ZincSearch exposes IZincSearchHttpClient interface with the main operations, required for sending logs. In order to use a custom HttpClient you can extend of default implementations:

  • Athena.Serilog.Sinks.ZincSearch.HttpClients.BaseZincSearchHttpClient (implements creation of internal HttpClient and setting credentials)
  • Athena.Serilog.Sinks.ZincSearch.HttpClients.ZincSearchHttpClient (default client which sends logs via HTTP)
  • Athena.Serilog.Sinks.ZincSearch.HttpClients.ZincSearchGzipHttpClient (default client which sends logs via HTTP with gzip compression)

or create one implementing Athena.Serilog.Sinks.ZincSearch.IZincSearchHttpClient.

// CustomHttpClient.cs

public class CustomHttpClient : BaseZincSearchHttpClient
{
    public override Task<HttpResponseMessage> PostAsync(string requestUri, Stream contentStream)
    {
        return base.PostAsync(requestUri, contentStream);
    }
}
// Usage

Log.Logger = new LoggerConfiguration()
    .WriteTo.ZincSearch(
         "http://localhost:4080",
         index: "zincsearch_test",
         credentials: new ZincSearchCredentials{
            Username = "admin",
            Password = "123456"
         },
         httpClient: new CustomHttpClient()
    )
    .CreateLogger();

Sending json content to ZincSearch

From v8 Athena.Serilog.Sinks.ZincSearch uses ZincSearchJsonTextFormatter by default, which allows to send logs to ZincSearch as a JSON-payloads. This allows easier filtering in ZincSearch v2, more information about how to filter can be found here

Also, you could implement your own formatter, implementing Serilog.Formatting.ITextFormatter interface and pass it to the sink configuration.

Example configuration:

{
  "Serilog": {
    "Using": ["Athena.Serilog.Sinks.ZincSearch"],
    "MinimumLevel": {
      "Default": "Debug"
    },
    "WriteTo": [
      {
        "Name": "ZincSearch",
        "Args": {
          "uri": "http://localhost:4080",
          "index": "zincsearch_test",
          "credentials": {
            "username": "admin",
            "password": "123456"
          },
          "textFormatter": "My.Awesome.Namespace.MyTextFormatter, MyCoolAssembly"
        }
      }
    ]
  }
}

Inspiration and Credits

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
8.0.0 121 9/7/2024
1.0.2 198 5/27/2024
1.0.1 117 5/23/2024
1.0.0 94 5/11/2024

For release notes, please see the change log on GitHub.