ecs-dotnet icon indicating copy to clipboard operation
ecs-dotnet copied to clipboard

[BUG] - Serilog: field server is not set when MapHttpAdapter is null, even though server can be set from standard Serilog enricher fields.

Open AThomsen opened this issue 3 years ago • 0 comments

Elastic.CommonSchema.Serilog

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

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

.NET framework / OS: .NET 6, Win 10

Description of the problem, including expected versus actual behavior:

Goal: I want to log what user (service account) context the process runs in.

Scenario:

  • No MapHttpAdapter is set.
  • Serilog is configured with .Enrich.WithEnvironmentUserName()

Expected: Windows user running the service should be set in field server.user.

Actual: server.user is not set.

Possible fix: Move ecsEvent.Server = GetServer(logEvent, configuration); outside the if (configuration.MapHttpAdapter != null) scope here: https://github.com/elastic/ecs-dotnet/blob/909c4655ea1b9217fd6c41ca987df007e774134f/src/Elastic.CommonSchema.Serilog/LogEventConverter.cs#L70

AThomsen avatar Jan 28 '22 08:01 AThomsen