![]() |
VOOZH | about |
dotnet add package Elastic.CommonSchema.Serilog --version 9.0.0
NuGet\Install-Package Elastic.CommonSchema.Serilog -Version 9.0.0
<PackageReference Include="Elastic.CommonSchema.Serilog" Version="9.0.0" />
<PackageVersion Include="Elastic.CommonSchema.Serilog" Version="9.0.0" />Directory.Packages.props
<PackageReference Include="Elastic.CommonSchema.Serilog" />Project file
paket add Elastic.CommonSchema.Serilog --version 9.0.0
#r "nuget: Elastic.CommonSchema.Serilog, 9.0.0"
#:package Elastic.CommonSchema.Serilog@9.0.0
#addin nuget:?package=Elastic.CommonSchema.Serilog&version=9.0.0Install as a Cake Addin
#tool nuget:?package=Elastic.CommonSchema.Serilog&version=9.0.0Install as a Cake Tool
This ITextFormatter implementation formats a Serilog event into a JSON representation that adheres to the Elastic Common Schema specification.
The .NET assemblies are published to NuGet under the package name Elastic.CommonSchema.Serilog
var logger = new LoggerConfiguration()
.WriteTo.Console(new EcsTextFormatter())
.CreateLogger();
In the code snippet above new EcsTextFormatter() enables the text formatter and instructs Serilog to format the event as JSON. The sample above uses the Console sink, but you are free to use any sink of your choice, perhaps consider using a filesystem sink and Elastic Filebeat for durable and reliable ingestion.
In ASP.NET (core) applications
.UseSerilog((ctx, config) =>
{
// Ensure HttpContextAccessor is accessible
var httpAccessor = ctx.Configuration.Get<HttpContextAccessor>();
config
.ReadFrom.Configuration(ctx.Configuration)
.Enrich.WithEcsHttpContext(httpAccessor)
.WriteTo.Async(a => a.Console(new EcsTextFormatter()));
})
The WithEcsHttpContext ensures logs will be enriched with HttpContext data.
An example of the output is given below:
{
"@timestamp": "2019-11-22T14:59:02.5903135+11:00",
"log.level": "Information",
"message": "Info \"X\" 2.2",
"ecs.version": "9.0.0",
"log": { "logger": "Elastic.CommonSchema.Serilog.Tests.MessageTests" },
"labels": {
"MessageTemplate": "Info {ValueX} {SomeY}",
"ValueX": "X",
"ThreadName": ".NET Long Running Task"
},
"agent": {
"type": "Elastic.CommonSchema.Serilog",
"version": "1.6.0"
},
"event": {
"created": "2019-11-22T14:59:02.5903135+11:00",
"severity": 2,
"timezone": "Romance Standard Time"
},
"host": {
"os": {
"full": "Microsoft Windows 10.0.19045",
"platform": "Win32NT",
"version": "10.0.19045.0"
},
"architecture": "X64",
"hostname": "LOCALHOST",
"name": "LOCALHOST"
},
"process": {
"name": "dotnet",
"pid": 1440,
"thread.id": 15,
"thread.name": ".NET Long Running Task",
"title": ""
},
"server": { "user": { "name": "MyDomain\\MyUserName" } },
"service": {
"name": "Elastic.CommonSchema",
"type": "dotnet",
"version": "1.6.0"
},
"user": {
"domain": "MyDomain",
"name": "MyUserName"
},
"metadata": {
"SomeY": 2.2
}
}
| Option | Description | |
|---|---|---|
MapCurrentThead |
true map ecs.process by looking up the Process from the current thread |
|
MapHttpAdapter |
null a way to map HttpContextAccessor to ECS fields. |
|
LogEventsPropertiesToFilter |
A Set<string> of properties that should not be emitted as labels.* or metadata.* |
|
MapCustom |
A Func that allows you to mutate the EcsDocument before its fully converted. |
This formatter also 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 software is Copyright (c) 2014-2020 by Elasticsearch BV.
This is free software, licensed under: The Apache License Version 2.0.
| 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 is compatible. 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.CommonSchema.Serilog:
| Package | Downloads |
|---|---|
|
Elastic.Serilog.Sinks
Package Description |
|
|
Serilog.Sinks.Logz.Io
Serilog event sink that sends logs to Logz.io. |
|
|
Elastic.Serilog.Enrichers.Web
Serilog enricher for ASP.NET (Core) to inject more data in emitted Elastic Common Schema (ECS) documents. |
|
|
Sitko.Core.ElasticStack
Sitko.Core is a set of libraries to help build .NET Core applications fast |
|
|
BioEngine.Extra.ElasticStack
Package Description |
Showing the top 3 popular GitHub repositories that depend on Elastic.CommonSchema.Serilog:
| Repository | Stars |
|---|---|
|
jerrytang67/SoMall
社交电商商城开源项目.socail+mall即取名SoMall ,abp netcore 3.1 angular vue uni-app typescript docker mssql
|
|
|
damikun/trouble-training
FullStack DDD/CQRS with GraphQL workshop including distributed tracing and monitoring. This shows the configuration from React frontend to .Net backend.
|
|
|
sitkoru/Sitko.Core
Sitko.Core is a set of libraries to help build .NET Core applications fast
|
| Version | Downloads | Last Updated |
|---|---|---|
| 9.0.0 | 2,860,968 | 8/13/2025 |
| 8.19.0 | 553,982 | 8/13/2025 |
| 8.18.2 | 1,005,139 | 6/27/2025 |
| 8.18.1 | 584,379 | 5/28/2025 |
| 8.12.3 | 4,096,783 | 11/26/2024 |
| 8.12.2 | 1,059,491 | 10/22/2024 |
| 8.12.1 | 721,241 | 10/3/2024 |
| 8.12.0 | 165,948 | 9/26/2024 |
| 8.11.1 | 2,021,514 | 6/10/2024 |
| 8.11.0 | 1,266,057 | 4/10/2024 |
| 8.6.1 | 3,391,919 | 8/3/2023 |
| 8.6.0 | 632,306 | 5/9/2023 |
| 8.4.0-alpha4 | 13,466 | 3/28/2023 |
| 8.4.0-alpha3 | 716 | 3/15/2023 |
| 8.4.0-alpha2 | 690 | 3/1/2023 |
| 8.4.0-alpha1 | 1,354 | 2/20/2023 |
| 1.6.0-alpha1 | 98,766 | 6/2/2021 |
| 1.5.3 | 9,668,423 | 6/1/2021 |
| 1.5.1 | 1,671,832 | 6/3/2020 |