Used nested format for ECS structure logging

Update `ElasticCommonSchemaStructuredLogFormatter` implementations so
that nested JSON is used for entries that previous has a '.' in the
name. This format follows the ECS specification and should be compatible
with more backends.

Fixes gh-45063
This commit is contained in:
Phillip Webb
2025-04-14 12:32:27 -07:00
parent baa8d1a333
commit 5b165b35e3
12 changed files with 279 additions and 91 deletions

View File

@@ -504,7 +504,7 @@ A log line looks like this:
[source,json]
----
{"@timestamp":"2024-01-01T10:15:00.067462556Z","log.level":"INFO","process.pid":39599,"process.thread.name":"main","service.name":"simple","log.logger":"org.example.Application","message":"No active profile set, falling back to 1 default profile: \"default\"","ecs.version":"8.11"}
{"@timestamp":"2024-01-01T10:15:00.067462556Z","log":{"level":"INFO","logger":"org.example.Application"},"process":{"pid":39599,"thread":{"name":"main"}},"service":{"name":"simple"},"message":"No active profile set, falling back to 1 default profile: \"default\"","ecs":{"version":"8.11"}}
----
This format also adds every key value pair contained in the MDC to the JSON object.