elastic / ecs-dotnet

https://www.elastic.co/guide/en/ecs-logging/dotnet/current/setup.html
Apache License 2.0
108 stars 54 forks source link

[BUG] Metadata EventId.Name not being set #407

Open cjlotz opened 1 month ago

cjlotz commented 1 month ago

ECS integration/library project(s) (e.g. Elastic.CommonSchema.Serilog): Serilog.Sinks.ElasticSearch

ECS schema version (e.g. 1.4.0): 8.11.1

ECS .NET assembly version (e.g. 1.4.2): 8.11.1

Elasticsearch version (if applicable): 8

.NET framework / OS: .NET 8/Windows

Description of the problem, including expected versus actual behavior:

After upgrading from the 8.11.0 to 8.11.1, it seems like the Microsoft.Extensions.Logging.EventId.Name is not being mapped to metadata.EventId.Name anymore

Here's is some sample snippets of an event definition:

public static readonly EventId SystemEventHandled = new(LoggingConstants.RuntimeEvents + 78, nameof(SystemEventHandled));

private static readonly Action<ILogger, string, Exception> _systemEventHandled = LoggerMessage.Define<string>(
      LogLevel.Information, RuntimeEvents.SystemEventHandled, "{EventAction}");

Here is the output of events logged using 8.11.0 as seen in Kibana. Notice that the metadata.EventId.Name is set (4th column)

working-8 11 0

Here is the output of events after updating to 8.11.1. Notice that the metadata.EventId.Name is now not being set

not-working-8 11 1

No code changes where made except for updating the NuGet package reference for Elastic.CommonSchema.Serilog from 8.11.0 to 8.11.1