Skip to content

Refine structured logging support #41491

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
philwebb opened this issue Jul 15, 2024 · 0 comments
Closed

Refine structured logging support #41491

philwebb opened this issue Jul 15, 2024 · 0 comments
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@philwebb
Copy link
Member

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.

@philwebb philwebb added the type: enhancement A general enhancement label Jul 15, 2024
@philwebb philwebb added this to the 3.4.x milestone Jul 15, 2024
@philwebb philwebb self-assigned this Jul 16, 2024
philwebb added a commit that referenced this issue Jul 24, 2024
Update `ApplicationPid` with `toLong()` and `isAvailable()` methods to
make it easier to use with structured logging.

See gh-41491
philwebb added a commit that referenced this issue Jul 24, 2024
Add `formatToBytes()` method for use with structured logging.

See gh-41491
@philwebb philwebb modified the milestones: 3.4.x, 3.4.0-M2 Jul 24, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant