Skip to content

ECS structured logging writes empty service and service.node objects - #52495

Merged
philwebb merged 1 commit into
spring-projects:4.0.xfrom
b84330808:ecs-empty-service-node
Oct 29, 2026
Merged

philwebb merged 1 commit into
spring-projects:4.0.xfrom
b84330808:ecs-empty-service-node

Conversation

@b84330808

Copy link
Copy Markdown
Contributor

With logging.structured.format.console=ecs, every log line contains an empty node object unless logging.structured.ecs.service.node-name is set. For example, with only spring.application.name=app:

"service":{"name":"app","node":{}}

and without any service details:

"service":{"node":{}}

The other service members use whenHasLength(), but service and service.node are always written. This only writes service.node when there is a node name, and only writes service when at least one of its members has a value. service.node.name keeps the same path, so renames and excludes work as before.

ElasticCommonSchemaPropertiesTests.addToJsonMembersWhenNoNodeNameDoesNotAddNode and addToJsonMembersWhenNoServiceValuesDoesNotAddService fail without the change and pass with it.

I used Claude Code to write this change.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue that has not yet been triaged. Contributions will not be accepted. label Oct 29, 2026
@philwebb philwebb self-assigned this Oct 29, 2026
@philwebb philwebb added type: bug A general bug and removed status: waiting-for-triage An issue that has not yet been triaged. Contributions will not be accepted. labels Oct 29, 2026
@philwebb philwebb added this to the 4.0.x milestone Oct 29, 2026
Update `ElasticCommonSchemaProperties` to omit "service" and
"service.node" objects if they have no contents.

See spring-projectsgh-52495

Signed-off-by: Wei-Lun Li <b84330808@gmail.com>
@philwebb philwebb modified the milestones: 4.0.x, 4.0.10 Oct 29, 2026
@philwebb
philwebb force-pushed the ecs-empty-service-node branch from 0fa07a9 to bc9b3a1 Compare October 29, 2026 20:28
@philwebb
philwebb merged commit b7f4c7d into spring-projects:4.0.x Oct 29, 2026
2 checks passed
@philwebb

Copy link
Copy Markdown
Member

Thanks @b84330808

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug A general bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants