![]() |
VOOZH | about |
dotnet add package Elastic.Serilog.Sinks --version 9.0.0
NuGet\Install-Package Elastic.Serilog.Sinks -Version 9.0.0
<PackageReference Include="Elastic.Serilog.Sinks" Version="9.0.0" />
<PackageVersion Include="Elastic.Serilog.Sinks" Version="9.0.0" />Directory.Packages.props
<PackageReference Include="Elastic.Serilog.Sinks" />Project file
paket add Elastic.Serilog.Sinks --version 9.0.0
#r "nuget: Elastic.Serilog.Sinks, 9.0.0"
#:package Elastic.Serilog.Sinks@9.0.0
#addin nuget:?package=Elastic.Serilog.Sinks&version=9.0.0Install as a Cake Addin
#tool nuget:?package=Elastic.Serilog.Sinks&version=9.0.0Install as a Cake Tool
A Serilog sink that writes logs directly to Elasticsearch or Elastic Cloud using the Elastic Common Schema.
NOTE: To use version 9.0.0 of the sink you need atleast version 8.15.0 of the Elastic Stack.
There's a few ways that you can extend a Serilog LoggerConfiguration:
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.Enrich.FromLogContext()
NOTE: Don't forget we also publish an for the Elastic APM Agent!
Writing to Elasticsearch
.WriteTo.Elasticsearch(new [] { new Uri("http://localhost:9200" )}, opts =>
{
opts.DataStream = new DataStreamName("logs", "console-example", "demo");
opts.BootstrapMethod = BootstrapMethod.Failure;
opts.ConfigureChannel = channelOpts =>
{
channelOpts.BufferOptions = new BufferOptions
{
ConcurrentConsumers = 10
};
};
})
Writing to Elastic Cloud:
.WriteTo.ElasticCloud("cloudId", "cloudUser", "cloudPass", opts =>
opts is an instance of ElasticsearchSinkOptions with the following options
| Option | Description |
|---|---|
Transport |
An instance of Elastic.Transport that dictates where and how wer are communicating to. Defaults to http://localhost:9200 |
DataStream |
Where to write data, defaults to the logs-dotnet-default datastream. |
BootstrapMethod |
Wheter the sink should attempt to install component and index templates to ensure the datastream has ECS mappings. Can be be either None (the default), Silent (attempt but fail silently), Failure (attempt and fail with exceptions if bootstrapping fails). |
TextFormatting |
Allows explicit control of over the EcsTextFormatterConfiguration used to emit ECS json documents. See Elastic.CommonSchema.Serilog for available options. |
ConfigureChannel |
A callback receiving the DatastreamChannelOptions which allows you to control sizing, backpressure etc. See Elastic.Ingest.Elasticsearch for more information. |
Note that you can also pass ElasticsearchSinkOptions directly
.WriteTo.Elasticsearch(new ElasticsearchSinkOptions(client.Transport)
This allows you to reuse the Transport used by the Elasticsearch Client for instance.
This sink by proxy of its formatter allows you to set ECS fields directly from the message template using properties that adhere to the https://messagetemplates.org/ format.
The available ECS message template properties are listed under LogTemplateProperties.* e.g LogTemplateProperties.TraceId
Log.Information("The time is {TraceId}", "my-trace-id");
Will override trace.id on the resulting ECS json document.
This sink can be configured through appsettings.json when used in combination with Serilog.Settings.Configuration.
When configuring through appsettings only the bootstrapMethod configuration is required
{
"Serilog": {
"Using": [ "Elastic.Serilog.Sinks" ],
"MinimumLevel": { "Default": "Information" },
"WriteTo": [
{
"Name": "Elasticsearch",
"Args": {
"bootstrapMethod": "Silent",
"nodes": [ "http://elastichost:9200" ],
"useSniffing": true,
"apiKey": "<apiKey>",
"username": "<username>",
"password": "<password>",
"ilmPolicy" : "my-policy",
"dataStream" : "logs-dotnet-default",
"includeHost" : true,
"includeUser" : true,
"includeProcess" : true,
"includeActivity" : true,
"filterProperties" : [ "prop1", "prop2" ],
"proxy": "http://localhost:8200",
"proxyUsername": "x",
"proxyPassword": "y",
"debugMode": false,
//EXPERT settings, do not set unless you need to
"maxRetries": 3,
"maxConcurrency": 20,
"maxInflight": 100000,
"maxExportSize": 1000,
"maxLifeTime": "00:00:05",
"fullMode": "Wait"
}
}
]
}
}
When configuring through appsettings only the bootstrapMethod configuration is required
You can specify either endpoint or cloudId, cloudId will take precedence.
You'll need to specify either apiKey or username and password.
{
"Serilog": {
"Using": [ "Elastic.Serilog.Sinks" ],
"MinimumLevel": { "Default": "Information" },
"WriteTo": [
{
"Name": "ElasticCloud",
"Args": {
"bootstrapMethod": "Silent",
"endpoint": "https://<redacted>.es.us-central1.gcp.cloud.es.io",
"cloudId": "<cloudId>",
"apiKey": "<apiKey>",
"username": "<username>",
"password": "<password>",
"ilmPolicy" : "my-policy",
"dataStream" : "logs-dotnet-default",
"includeHost" : true,
"includeUser" : true,
"includeProcess" : true,
"includeActivity" : true,
"filterProperties" : [ "prop1", "prop2" ],
"proxy": "http://localhost:8200",
"proxyUsername": "x",
"proxyPassword": "y",
"debugMode": false,
//EXPERT settings, do not set unless you need to
"maxRetries": 3,
"maxConcurrency": 20,
"maxInflight": 100000,
"maxExportSize": 1000,
"maxLifeTime": "00:00:05",
"fullMode": "Wait"
}
}
]
}
}
Serilog.Sinks.ElasticsearchSerilog.Sinks.Elasticsearch is an amazing community led sink that has a ton of options and works against older Elasticsearch versions < 8.0.Serilog.Sinks.Elasticsearch is unofficially supported by Elastic with some of the .NET team helping to maintain it.Elastic.Serilog.Sinks is officially supported by Elastic and was purposely build to adhere to newer best practices around logging, datastreams and ILM.Elastic.Serilog.Sinks is purposely build to have fewer configuration options and be more prescriptive than Serilog.Sinks.Elasticsearch.
Elastic.Serilog.SinksElastic.Serilog.Sinks only works with Elasticsearch 8.x and up.
BootstrapMethod) attempts to load templates build for Elasticsearch 8.0 and up.Elastic.Serilog.Sinks has only one way it emits data to Elasticsearch confirming to the ecs-logging specification
Elastic.Serilog.Sinks has no durable mode.
Serilog.Sinks.File with our ECS log formatter for Serilog and use filebeat to ship these logs.If you miss a particular feature from Serilog.Sinks.Elasticsearch in Elastic.Serilog.Sinks please open a feature request! We'd love to grow this sink organically moving forward.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 is compatible. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on Elastic.Serilog.Sinks:
| Package | Downloads |
|---|---|
|
SyncSoft.App.Serilog
An app framework for SyncSoft Inc. |
|
|
Intility.Extensions.Logging.Elasticsearch
Enable Elasticsearch logging provider. |
|
|
Delfin.Core.Infrastructure
An Infrastructure Layer library designed for Clean Architecture in .NET applications. This package provides the implementation of cross-cutting concerns such as data access, external service integration, and configuration management, ensuring that the application layers remain decoupled from infrastructure details. |
|
|
Xinghe.Utility
XH基础库(内部使用) |
|
|
Monq.Core.BasicDotNetMicroservice
NetCore Microservice extensions library that brings simplicity to configure asp.net and console programs as microservices. |
Showing the top 5 popular GitHub repositories that depend on Elastic.Serilog.Sinks:
| Repository | Stars |
|---|---|
|
mehdihadeli/food-delivery-microservices
🍔 A practical and cloud-native food delivery microservices, built with .Net Aspire, .Net 9, MassTransit, Domain-Driven Design, CQRS, Vertical Slice Architecture, Event-Driven Architecture, and the latest technologies.
|
|
| BehzadDara/SampleProject | |
|
mehdihadeli/vertical-slice-api-template
🍰 An asp.net core template based on .Net 9, Vertical Slice Architecture, CQRS, Minimal APIs, OpenTelemetry, API Versioning and OpenAPI.
|
|
|
omid-ahmadpour/CleanArchitecture-Template
This stands as a comprehensive solution template that embodies the principles of Clean Architecture, seamlessly integrated with the prowess of CQRS implementation, all within the ASP.NET Core framework.
|
|
|
zhuyongzhengs/Rex.ShopMicroService.Sample
一个基于ABP Framework 10.0、PostgreSQL、MongoDB、Redis、RabbitMQ、CAP、ElasticSearch、Minio、YARP的微服务电商商城平台,采用主流的互联网技术架构、全新的UI设计、可视化布局、支持集群部署;拥有活动促销、优惠卷、商品秒杀等众多完整的营销功能。
|
| Version | Downloads | Last Updated |
|---|---|---|
| 9.0.0 | 1,662,955 | 8/13/2025 |
| 8.19.0 | 370,767 | 8/13/2025 |
| 8.18.2 | 479,053 | 6/27/2025 |
| 8.18.1 | 387,496 | 5/28/2025 |
| 8.12.3 | 2,081,427 | 11/26/2024 |
| 8.12.2 | 481,252 | 10/22/2024 |
| 8.12.1 | 228,956 | 10/3/2024 |
| 8.12.0 | 93,151 | 9/26/2024 |
| 8.11.1 | 1,140,564 | 6/10/2024 |
| 8.11.0 | 357,268 | 4/10/2024 |
| 8.6.1 | 822,461 | 8/3/2023 |
| 8.6.0 | 145,781 | 5/9/2023 |