[BUG] Message generator property names are case sensitive
ECS integration/library project(s) (e.g. Elastic.CommonSchema.Serilog):
Elastic.CommonSchema.NLog = 8.11.0 but all will be impacted
.NET framework / OS: Net 8
Description of the problem, including expected versus actual behavior: When i pass ECS document fragments into my log generator the properties are only being added under label/metadata. But if i pass the same class with the property names changed to lowercase, the properties are overridden.
Steps to reproduce:
- Create a log generator
public static partial class Log
{
[LoggerMessage(Level = LogLevel.Information, Message = "Message")]
public static partial void UpdateEcsDocument(
this ILogger logger, [LogProperties(SkipNullProperties = true)] Elastic.CommonSchema.Event @event);
}
- Call the log generator
_logger.UpdateEcsDocument(new Elastic.CommonSchema.Event() { Timezone = "testing});
- Observe the properties from event which were set are added as "event.Timezone" to the labels property.
- Create own event class with property being called timezone
- Observe timezone is being updated
Notes The issue is set the AssignField Method within the EcsDocument is performing a case sensitive comparison hence properties are not being found and results in metadata/labels being used.
@Mpdreamz any chance you could take a quick look at removing the case sensitive as it will be a massive gain for me and the library.
I took a slightly different approach and opened: https://github.com/elastic/ecs-dotnet/pull/401
To allow ECS entities to be logged directly, they will always overwrite what was set previously.
Thanks @Mpdreamz appreciate the extensive changes. I assume that if the message generator has ignore null properties, then it won't override it?
Another question is will the solution you have implemented support nested objects which was a big limitation with removing the case sensitivity logic?
Closing this #401 covers it.
It will ignore null properties and supports nested objects.