Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] The fields event.code and event.action specified by the ECS standard are not written correct in dotnet core #356

Closed
HHobeck opened this issue Jan 19, 2024 · 4 comments · Fixed by #393
Labels
bug Something isn't working

Comments

@HHobeck
Copy link

HHobeck commented Jan 19, 2024

ECS integration/library project(s) (e.g. Elastic.CommonSchema.Serilog):
I'm using the Elastic.CommonSchema.Serilog.EcsTextFormatter, Elastic.CommonSchema.Serilog (8.6.1) to output my logs in the ECS standard.

ECS schema version (e.g. 1.4.0):
The ecs.version is 8.6.0

ECS .NET assembly version (e.g. 1.4.2):
Elastic.CommonSchema.Serilog.EcsTextFormatter, Elastic.CommonSchema.Serilog (8.6.1)

Elasticsearch version (if applicable):
n/a

.NET framework / OS:
.net 6.0 on windows 10

Description of the problem, including expected versus actual behavior:
When I'm logging a message with an EventId the properties like EventId.Id and EventId.Name are written in a metadata field. I would expect that the event information are stored in the documented fields in the ECS standard (please see specification for Event Fields).

var logger = loggerFactory.CreateLogger(GetType());
logger.LogWarning(new EventId(123, "hello"), "Hello {World}", "Universe");

Actual log output:

{
    "metadata": {
        "EventId": {
            "Id": 123,
            "Name": "hello"
        }
    }
...
}

Expected log output:

{
    "event": {
        "code": 123,
        "action": "hello"
    }
...
}
@HHobeck HHobeck added the bug Something isn't working label Jan 19, 2024
@Mpdreamz
Copy link
Member

Just to be sure are you using https://github.com/serilog/serilog-extensions-logging ?

@Mpdreamz
Copy link
Member

Just asking because vanilla extensions logging supports EventId

logEvent.Event = new Event { Action = eventId.Name, Code = eventId.Id.ToString(), Severity = LogEventToEcsHelper.GetSeverity(logLevel) };

Will add support for serilog/serilog-extensions-logging

@Mpdreamz
Copy link
Member

Opened #393 thanks for bringing this gap to our attention @HHobeck ! Sorry it took a bit for us to look into it.

@HHobeck HHobeck changed the title [BUG] The fields event.code and event.action specificed by the ECS standard are not written correct in dotnet core [BUG] The fields event.code and event.action specified by the ECS standard are not written correct in dotnet core May 29, 2024
@HHobeck
Copy link
Author

HHobeck commented May 29, 2024

Just to be sure are you using https://github.com/serilog/serilog-extensions-logging ?

Actually that is correct I'm using the following packages:

  • Serilog.Extensions.Logging 8.0.0
  • Serilog.Sinks.File 5.0.0

with the following configuration:

"Serilog": {
    "WriteTo:File": {
        "Name": "File",
        "Args": {
            "formatter": "Elastic.CommonSchema.Serilog.EcsTextFormatter, Elastic.CommonSchema.Serilog",
            "path": "./Logfiles/MyApplication-.log",
            "restrictedToMinimumLevel": "Verbose"
        }
    }
}

Thank you very much for taking the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants