ecs-dotnet
ecs-dotnet copied to clipboard
[BUG] Serilog serialization rendered message difference with serilog
ECS integration/library project(s) (e.g. Elastic.CommonSchema.Serilog): Elastic.CommonSchema.Serilog
ECS schema version (e.g. 1.4.0): Not specified
ECS .NET assembly version (e.g. 1.4.2): 1.5.3
Elasticsearch version (if applicable):
.NET framework / OS: .NET 6
Description of the problem, including expected versus actual behavior:
Expected rendered output: (config.WriteTo.Console(theme: AnsiConsoleTheme.Code);
w/ default serilog serializer setting)
ecs.net generated output WriteTo.Console(new EcsTextFormatter())
{
"@timestamp":"2022-05-30T18:10:57.3421777+09:00",
"log.level":"Information",
"message":"\"IReviewManagerGrain\"(0).\"AggregateAverageRating\"([3485]) returned value AverageRatingAggregation { AverageRating: 0, TotalCount: 0 }, Took 0ms",
"metadata":{
"message_template":"{Type}({Key}).{Name}({@Arguments}) returned value {@Result}, Took {Elapsed}ms",
"type":"IReviewManagerGrain",
"key":0,
"name":"AggregateAverageRating",
"arguments":[
3485
],
"result":{
"average_rating":0,
"total_count":0,
"$type":"AverageRatingAggregation"
},
"elapsed":0
},
"ecs":{
"version":"1.5.0"
},
"event":{
"severity":2,
"timezone":"Korea Standard Time",
"created":"2022-05-30T18:10:57.3421777+09:00"
},
"log":{
"logger":"Grey.MicroserviceFramework.Logging.LoggingCallFilter",
"original":null
},
"process":{
"thread":{
"id":43
},
"pid":25108,
"name":"Grey.Host",
"executable":"Grey.Host"
}
}
Steps to reproduce:
- Setup serilog with
WriteTo.Console(new EcsTextFormatter())
- Log
- Observe result is different
I've feeling that this issue is related to (https://github.com/elastic/ecs-dotnet/issues/168#issue-1038641469) because the internal serializer might be different than serilog's one, which causes this bug.
I think the log should be human readable and expectable (this is why we have message
field in the first place, right?)
Please make sure the output is same with serilog's one, or could we at least allow us to specify the "message renderer" at configuration?
EcsTextFormatter
is explicitly built to emit ECS logs as JSON
.
Sometimes this is exactly what you want on the console e.g k8s where stdout/err are logged generically and access to file logging is harder.
In other cases it makes more sense to use the default formatter on the console but use ECS's text formatter to write to file in the same configuration.
Closing this but feel free to reopen if I miss understood the ask here.