-
Notifications
You must be signed in to change notification settings - Fork 41.6k
Description
Our initial cut of structured logging support could do with a few small refinements. Specifically, the org.springframework.boot.logging.structured.ApplicationMetadata record feels like it's a little too tied to ECS. The environment and nodeName members aren't used in Logstash.
I think we should consider changing StructuredLogFormatter so that rather than injecting an ApplicationMetadata it can have a Spring Environment injected. We could then create a ECS specific helper class that could be bound from the environment and remove the need for ApplicationMetadata entirely.
In addition, if we inject an Envionment we may be able to simplify the log configuration. Currently it's hard to configure things like StructuredLogEncoder.serviceEnvironment. With Environment support we could move this into application.properties:
logging.structured.ecs.service.environment=foo
logging.structured.ecs.service.name=bar
...
Finally, we might also want to change StructuredLogFormatter so that it's not String based. We might be able to write directly to an Appendable rather than create a String that is immediately GC'd.