Athena.Serilog.Sinks.ZincSearch
1.0.0
See the version list below for details.
dotnet add package Athena.Serilog.Sinks.ZincSearch --version 1.0.0
NuGet\Install-Package Athena.Serilog.Sinks.ZincSearch -Version 1.0.0
<PackageReference Include="Athena.Serilog.Sinks.ZincSearch" Version="1.0.0" />
paket add Athena.Serilog.Sinks.ZincSearch --version 1.0.0
#r "nuget: Athena.Serilog.Sinks.ZincSearch, 1.0.0"
// Install Athena.Serilog.Sinks.ZincSearch as a Cake Addin #addin nuget:?package=Athena.Serilog.Sinks.ZincSearch&version=1.0.0 // Install Athena.Serilog.Sinks.ZincSearch as a Cake Tool #tool nuget:?package=Athena.Serilog.Sinks.ZincSearch&version=1.0.0
Athena.Serilog.Sinks.ZincSearch
ZincSearch Sink for Serilog
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"
}
}
}
]
}
}
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 internalHttpClient
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 | Versions 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. |
-
.NETStandard 2.0
- Serilog (>= 3.1.1)
- System.Text.Json (>= 4.7.0)
-
.NETStandard 2.1
- Serilog (>= 3.1.1)
- System.Text.Json (>= 4.7.0)
-
net5.0
- Serilog (>= 3.1.1)
- System.Text.Json (>= 4.7.0)
-
net6.0
- Serilog (>= 3.1.1)
- System.Text.Json (>= 4.7.0)
-
net7.0
- Serilog (>= 3.1.1)
- System.Text.Json (>= 4.7.0)
-
net8.0
- Serilog (>= 3.1.1)
- System.Text.Json (>= 4.7.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
For release notes, please see the change log on GitHub.