elastic / ecs-dotnet

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

[FEATURE] Support passing prepared EcsDocument object to the logging API #351

Open mrapavy opened 8 months ago

mrapavy commented 8 months ago

ECS integration/library project: Elastic.CommonSchema.Serilog

Is your feature request related to a problem? Please describe. The current implementation of Elastic.CommonSchema.Serilog only supports generating EcsDocument objects on the fly from a message template. That however means that every property I want modified in the output EcsDocument object needs to be present in the message template. While this works great for simple EcsDocument objects, it doesn't scale well when I need to:

Describe the solution you'd like In addition to accepting MEL message template with known template properties to manipulate the generated EcsDocument (as shown here), I would like to be able to pass prepared EcsDocument object to the logging API and have Elastic.CommonSchema.Serilog library serialize it as JSON into Serilog.

Optionally (when configured so), I would also like Elastic.CommonSchema.Serilog to enrich the prepared EcsDocument object with contextual data like: