Closed as not planned
Description
When using the structured log feature of Spring Boot 3.4 within a native image, custom log fields are not present.
In application.properties
:
logging.structured.format.console=ecs
logging.structured.ecs.service.environment=test
The service.environment
property is not present in the outputted logs.
Reproduction repo: https://github.com/Jul13nT/spring-native-structured-logging
First, run the application with spring-boot:run ./mvnw spring-boot:run
The produced log is:
{"@timestamp":"2025-01-16T14:59:06.731337409Z","log.level":"INFO","process.pid":211713,"process.thread.name":"main","service.name":"simple","service.environment":"test","log.logger":"com.test.SimpleApplication","message":"Started SimpleApplication in 1.278 seconds (process running for 1.625)","ecs.version":"8.11"}
"service.environment":"test"
is present.
Then, run the application in native image:
./mvnw spring-boot:build-image -Pnative
docker run --rm -p 8080:8080 spring-native-structured-logging:0.0.1-SNAPSHOT
The log is now:
{"@timestamp":"2025-01-16T15:04:36.133516Z","log.level":"INFO","process.pid":1,"process.thread.name":"main","service.name":"simple","log.logger":"com.test.SimpleApplication","message":"Started SimpleApplication in 0.069 seconds (process running for 0.075)","ecs.version":"8.11"}
The field service.environment
is missing.