{"id":15044644,"url":"https://github.com/elastic/ecs-dotnet","last_synced_at":"2025-05-14T18:02:20.651Z","repository":{"id":39535921,"uuid":"194950254","full_name":"elastic/ecs-dotnet","owner":"elastic","description":null,"archived":false,"fork":false,"pushed_at":"2025-05-06T16:03:52.000Z","size":3877,"stargazers_count":130,"open_issues_count":34,"forks_count":67,"subscribers_count":25,"default_branch":"main","last_synced_at":"2025-05-12T00:17:35.236Z","etag":null,"topics":["dotnet","ecs","elasticsearch"],"latest_commit_sha":null,"homepage":"https://www.elastic.co/guide/en/ecs-logging/dotnet/current/setup.html","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elastic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"contributing.md","funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-07-03T00:00:01.000Z","updated_at":"2025-05-06T16:01:47.000Z","dependencies_parsed_at":"2024-03-11T15:49:56.238Z","dependency_job_id":"d6dacd1e-64d5-4395-8624-06a1bb725991","html_url":"https://github.com/elastic/ecs-dotnet","commit_stats":{"total_commits":351,"total_committers":41,"mean_commits":8.560975609756097,"dds":0.6267806267806268,"last_synced_commit":"5b4004cc8435c9db1c9d48e6058ce26401ec2cf7"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elastic%2Fecs-dotnet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elastic%2Fecs-dotnet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elastic%2Fecs-dotnet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elastic%2Fecs-dotnet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elastic","download_url":"https://codeload.github.com/elastic/ecs-dotnet/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253655512,"owners_count":21943062,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dotnet","ecs","elasticsearch"],"created_at":"2024-09-24T20:50:50.626Z","updated_at":"2025-05-14T18:02:20.621Z","avatar_url":"https://github.com/elastic.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg align=\"right\" width=\"auto\" height=\"auto\" src=\"https://www.elastic.co/static-res/images/elastic-logo-200.png\"\u003e\n\n# Elastic Common Schema .NET\n\n[![Build Status](https://apm-ci.elastic.co/buildStatus/icon?job=apm-agent-dotnet%2Fecs-dotnet-mbp%2Fmain)](https://apm-ci.elastic.co/job/apm-agent-dotnet/job/ecs-dotnet-mbp/job/main/)\n\nThis repository contains .NET integrations that use the Elastic Common Schema (ECS), including popular .NET logging frameworks. Read the [announcement post](https://www.elastic.co/blog/elastic-common-schema-dotnet-library-and-integrations-released-for-elasticsearch).\n\nThe Elastic Common Schema defines a common set of fields for ingesting data into Elasticsearch. A common schema helps you correlate data from sources like logs and metrics or IT operations analytics and security analytics. Further information on ECS can be found in the official [Elastic documentation](https://www.elastic.co/guide/en/ecs/current/index.html) or [github repository](https://github.com/elastic/ecs).\n\nContributions are welcome, please read our [guidelines](https://github.com/elastic/ecs-dotnet/tree/main/contributing.md).\n\n---\n\n### Versioning\n\nVersion components: `{major}.{minor}.{patch}`\n\nThese libraries are not versioned according to [SemVer](https://semver.org/) principles. Backwards compatibility is only guaranteed within *minor* versions, since ECS only makes this guarantee. Patch releases of this library will not seek to introduce breaking changes, but will be used to address bug fixes within that minor version.\n\nEach assembly release indicates the ECS version that it is compatible with (see _releases_), but typically the minor version number of the assembly correlates to the compatible version of ECS; for example; all of `1.4.0`, `1.4.1`, `1.4.2` and `1.4.3` are compatible with ECS version `1.4.0`.\n\nThe assemblies are versioned using an assembly identity of `major.minor.*` as opposed to `major.*` as is common when following SemVer.\n\n---\n\n# Integrations\n\nOfficial NuGet packages can be referenced from [NuGet.org](https://www.nuget.org).\n\n| Package Name            | Purpose          | Download         |\n| ----------------------- | ---------------- | -----------------|\n| `Elastic.CommonSchema`  |  Foundational project that contains a full C# representation of ECS, used by the other integrations listed. | [![NuGet Release][ElasticCommonSchema-image]][ElasticCommonSchema-nuget-url]  |\n| `Elastic.CommonSchema.Serilog`  |  Formats a Serilog log message into a JSON representation that can be indexed into Elasticsearch. | [![NuGet Release][ElasticCommonSchemaSerilog-image]][ElasticCommonSchemaSerilog-nuget-url]  |\n| `Elastic.CommonSchema.NLog`  |  Formats an NLog message into a JSON representation that can be indexed into Elasticsearch. | [![NuGet Release][ElasticCommonSchemaNLog-image]][ElasticCommonSchemaNLog-nuget-url]  |\n| `Elastic.CommonSchema.Log4net`  |  Formats a log4net message into a JSON representation that can be indexed into Elasticsearch. | [![NuGet Release][ElasticCommonSchemaLog4net-image]][ElasticCommonSchemaLog4net-nuget-url]  |\n| `Elastic.Extensions.Logging`  | Microsoft Extension Logging provider that writes directly to ElasticSearch or ElasticCloud. | [![NuGet Release][ElasticIngestLogging-image]][ElasticIngestLogging-nuget-url]  |\n| `Elastic.NLog.Targets`  | NLog target that writes directly to ElasticSearch or ElasticCloud. | [![NuGet Release][ElasticIngestNLog-image]][ElasticIngestNLog-nuget-url]  |\n| `Elastic.Serilog.Sinks`  | Serilog sink that writes directly to ElasticSearch or ElasticCloud. | [![NuGet Release][ElasticIngestSerilog-image]][ElasticIngestSerilog-nuget-url]  |\n| `Elastic.Apm.SerilogEnricher`   |  Adds transaction id and trace id to every Serilog log message that is created during a transaction. This works in conjunction with the Elastic.CommonSchema.Serilog package and forms a solution to distributed tracing with Serilog. | [![NuGet Release][ElasticApmSerilogEnricher-image]][ElasticApmSerilogEnricher-nuget-url]  |\n| `Elastic.Apm.NLog`              |  Introduces two special placeholder variables (ElasticApmTraceId and ElasticApmTransactionId) for use within your NLog templates. | [![NuGet Release][ElasticApmNLog-image]][ElasticApmNLog-nuget-url]  |\n| `Elastic.CommonSchema.BenchmarkDotNetExporter`  |  An exporter for BenchmarkDotnet that can index benchmarking results directly into Elasticsearch, which can be helpful for detecting code-related performance problems over time. | [![NuGet Release][ElasticBenchmarkDotNetExporter-image]][ElasticBenchmarkDotNetExporter-nuget-url]  |\n\n[ElasticCommonSchema-nuget-url]:https://www.nuget.org/packages/Elastic.CommonSchema/\n[ElasticCommonSchema-image]:https://img.shields.io/nuget/v/Elastic.CommonSchema.svg\n\n[ElasticCommonSchemaSerilog-nuget-url]:https://www.nuget.org/packages/Elastic.CommonSchema.Serilog/\n[ElasticCommonSchemaSerilog-image]:https://img.shields.io/nuget/v/Elastic.CommonSchema.Serilog.svg\n\n[ElasticCommonSchemaNLog-nuget-url]:https://www.nuget.org/packages/Elastic.CommonSchema.NLog/\n[ElasticCommonSchemaNLog-image]:https://img.shields.io/nuget/v/Elastic.CommonSchema.NLog.svg\n\n[ElasticCommonSchemaLog4net-nuget-url]:https://www.nuget.org/packages/Elastic.CommonSchema.Log4net/\n[ElasticCommonSchemaLog4net-image]:https://img.shields.io/nuget/v/Elastic.CommonSchema.Log4net.svg\n\n[ElasticIngestLogging-nuget-url]:https://www.nuget.org/packages/Elastic.Extensions.Logging/\n[ElasticIngestLogging-image]:https://img.shields.io/nuget/v/Elastic.Extensions.Logging.svg\n\n[ElasticIngestNLog-nuget-url]:https://www.nuget.org/packages/Elastic.NLog.Targets/\n[ElasticIngestNLog-image]:https://img.shields.io/nuget/v/Elastic.NLog.Targets.svg\n\n[ElasticIngestSerilog-nuget-url]:https://www.nuget.org/packages/Elastic.Serilog.Sinks/\n[ElasticIngestSerilog-image]:https://img.shields.io/nuget/v/Elastic.Serilog.Sinks.svg\n\n[ElasticApmSerilogEnricher-nuget-url]:https://www.nuget.org/packages/Elastic.Apm.SerilogEnricher/\n[ElasticApmSerilogEnricher-image]:https://img.shields.io/nuget/v/Elastic.Apm.SerilogEnricher.svg\n\n[ElasticApmNLog-nuget-url]:https://www.nuget.org/packages/Elastic.Apm.NLog/\n[ElasticApmNLog-image]:https://img.shields.io/nuget/v/Elastic.Apm.NLog.svg\n\n[ElasticBenchmarkDotNetExporter-nuget-url]:https://www.nuget.org/packages/Elastic.CommonSchema.BenchmarkDotNetExporter/\n[ElasticBenchmarkDotNetExporter-image]:https://img.shields.io/nuget/v/Elastic.CommonSchema.BenchmarkDotNetExporter.svg\n\n## Foundation Library\n\n### [Elastic.CommonSchema](https://github.com/elastic/ecs-dotnet/tree/main/src/Elastic.CommonSchema)\n\nFoundational project that contains a full C# representation of ECS. [Learn more...](https://github.com/elastic/ecs-dotnet/tree/main/src/Elastic.CommonSchema)\n\n## Logging\n\n### [Elastic.Extensions.Logging](src/Elastic.Extensions.Logging/ReadMe.md)\n\nElastic Stack (ELK) logger provider for `Microsoft.Extensions.Logging`.\n\nWrites direct to Elasticsearch using the Elastic Common Schema, with semantic logging of structured data from message and scope values.\n\nThis logger provider can be added directly to Microsoft.Extensions.Logging:\n\n```csharp\nusing Elastic.Extensions.Logging;\n\n// ...\n\n    .ConfigureLogging((hostContext, loggingBuilder) =\u003e\n    {\n        loggingBuilder.AddElasticsearch();\n    })\n```\n\n### [Elastic.CommonSchema.Serilog](https://github.com/elastic/ecs-dotnet/tree/main/src/Elastic.CommonSchema.Serilog)\n\nFormats a Serilog event into a JSON representation that adheres to the Elastic Common Schema. [Learn more...](https://github.com/elastic/ecs-dotnet/tree/main/src/Elastic.CommonSchema.Serilog)\n\n```csharp\nvar logger = new LoggerConfiguration()\n    .WriteTo.Console(new EcsTextFormatter())\n    .CreateLogger();\n```\n\nSerilog Sink [Elastic.Serilog.Sinks](https://github.com/elastic/ecs-dotnet/tree/main/src/Elastic.Serilog.Sinks) is also available, which writes directly to Elasticsearch using the Elastic Common Schema.\n\n### [Elastic.CommonSchema.NLog](https://github.com/elastic/ecs-dotnet/tree/main/src/Elastic.CommonSchema.NLog)\n\nFormats an NLog event into a JSON representation that adheres to the Elastic Common Schema. [Learn more...](https://github.com/elastic/ecs-dotnet/tree/main/src/Elastic.CommonSchema.NLog)\n\n```csharp\nvar config = new LoggingConfiguration();\nvar consoleTarget = new ConsoleTarget(\"console\") { Layout = new EcsLayout() };  // Use the ECS layout.\nconfig.AddRule(LogLevel.Debug, LogLevel.Fatal, consoleTarget);\nLogManager.Configuration = config;\nvar logger = LogManager.GetCurrentClassLogger();\n```\n\nNLog Target [Elastic.NLog.Targets](https://github.com/elastic/ecs-dotnet/tree/main/src/Elastic.NLog.Targets) is also available, which writes directly to Elasticsearch using the Elastic Common Schema.\n\n### [Elastic.CommonSchema.Log4net](https://github.com/elastic/ecs-dotnet/tree/main/src/Elastic.CommonSchema.Log4net)\n\nFormats a log4net event into a JSON representation that adheres to the Elastic Common Schema. [Learn more...](https://github.com/elastic/ecs-dotnet/tree/main/src/Elastic.CommonSchema.Log4net)\n\n```csharp\nvar hierarchy = (Hierarchy)LogManager.CreateRepository(Guid.NewGuid().ToString());\nvar appender = new ConsoleAppender { Layout = new EcsLayout() }; // Use the ECS layout.\nhierarchy.Root.AddAppender(appender);\nhierarchy.Root.Level = Level.All;\nhierarchy.Configured = true;\n```\n\n## APM\n\n### [Elastic.Apm.SerilogEnricher](https://github.com/elastic/ecs-dotnet/tree/main/src/Elastic.Apm.SerilogEnricher)\n\nAdds transaction id and trace id to every Serilog log message that is created during a transaction. [Learn more...](https://github.com/elastic/ecs-dotnet/tree/main/src/Elastic.Apm.SerilogEnricher)\n\n```csharp\nvar logger = new LoggerConfiguration()\n    .Enrich.WithElasticApmCorrelationInfo()\n    .WriteTo.Console(outputTemplate: \"[{ElasticApmTraceId} {ElasticApmTransactionId} {Message:lj} {NewLine}{Exception}\")\n    .CreateLogger();\n```\n\nWhen combined with `Elastic.CommonSchema.Serilog` the trace and transaction id will automatically appear in ECS as well.\n\n```csharp\nvar logger = new LoggerConfiguration()\n    .Enrich.WithElasticApmCorrelationInfo()\n    .WriteTo.Console(new EcsTextFormatter()) // APM information persisted in ECS as well\n    .CreateLogger();\n```\n\n### [Elastic.Apm.NLog](https://github.com/elastic/ecs-dotnet/tree/main/src/Elastic.Apm.NLog)\n\nIntroduce two special place holder variables (`ElasticApmTraceId`, `ElasticApmTransactionId`) easily into your NLog templates.\n[Learn more...](https://github.com/elastic/ecs-dotnet/tree/main/src/Elastic.Apm.NLog)\n\n```csharp\n// Logged message will be in format of `trace-id|transation-id|InTransaction`\n// or `||InTransaction` if the place holders are not available\nvar consoleTarget = new ConsoleTarget(\"console\");\nconsoleTarget.Layout = \"${ElasticApmTraceId}|${ElasticApmTransactionId}|${message}\";\nconfig.AddRule(LogLevel.Debug, LogLevel.Fatal, consoleTarget);\nLogManager.Configuration = config;\nvar logger = LogManager.GetCurrentClassLogger();\n```\n\nWhen using EcsLayout from `Elastic.CommonSchema.NLog` then trace and transaction id will automatically appear in ECS.\n\n## Benchmarking\n\n### [Elastic.CommonSchema.BenchmarkDotNetExporter](https://github.com/elastic/ecs-dotnet/tree/main/src/Elastic.CommonSchema.BenchmarkDotNetExporter)\n\nAn exporter for [BenchmarkDotnet](https://github.com/dotnet/BenchmarkDotNet) that can index benchmarking result output directly into Elasticsearch. [Learn more...](https://github.com/elastic/ecs-dotnet/tree/main/src/Elastic.CommonSchema.BenchmarkDotNetExporter)\n\n```csharp\nvar options = new ElasticsearchBenchmarkExporterOptions(url)\n{\n\tGitBranch = \"externally-provided-branch\",\n\tGitCommitMessage = \"externally provided git commit message\",\n\tGitRepositoryIdentifier = \"repository\"\n};\nvar exporter = new ElasticsearchBenchmarkExporter(options);\n\nvar config = CreateDefaultConfig().With(exporter);\nBenchmarkRunner.Run(typeof(Md5VsSha256), config);\n```\n\n# Examples\n\n- [Elastic.CommonSchema.Serilog and ASP.NET Core](/examples/aspnetcore-with-serilog/)\n\n## Copyright and License\n\nThis software is Copyright (c) 2014-2020 by Elasticsearch BV.\n\nThis is free software, licensed under: [The Apache License Version 2.0](https://github.com/elastic/ecs-dotnet/blob/main/license.txt).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felastic%2Fecs-dotnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felastic%2Fecs-dotnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felastic%2Fecs-dotnet/lists"}