Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Native image ignore structured logging fields #43861

Closed
Jul13nT opened this issue Jan 16, 2025 · 4 comments
Closed

Native image ignore structured logging fields #43861

Jul13nT opened this issue Jan 16, 2025 · 4 comments
Labels
status: superseded An issue that has been superseded by another

Comments

@Jul13nT
Copy link

Jul13nT commented Jan 16, 2025

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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 16, 2025
@wilkinsona
Copy link
Member

wilkinsona commented Jan 16, 2025

Thanks for the report, @Jul13nT. I suspect we're missing reflection hints that allow the binding of logging.structured.ecs properties to org.springframework.boot.logging.structured.ElasticCommonSchemaProperties.

We may have a similar problems with binding logging.structured.json to StructuredLoggingJsonProperties and logging.structured.gelf to GraylogExtendedLogFormatProperties.

@wilkinsona wilkinsona added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Jan 16, 2025
@wilkinsona wilkinsona added this to the 3.4.x milestone Jan 16, 2025
@nosan
Copy link
Contributor

nosan commented Jan 16, 2025

If you haven’t started working on it yet, @wilkinsona, would it be okay if I took it on?

@wilkinsona
Copy link
Member

Yes please, @nosan, that'd be great.

nosan added a commit to nosan/spring-boot that referenced this issue Jan 16, 2025
Add RuntimeHints for GraylogExtendedLogFormatProperties,
StructuredLoggingJsonProperties and ElasticCommonSchemaProperties
properties.

Add BeanFactoryInitializationAotProcessor for registering RuntimeHints
for a custom StructuredLoggingJsonMembersCustomizer.

See spring-projectsgh-43861

Signed-off-by: Dmytro Nosan <[email protected]>
nosan added a commit to nosan/spring-boot that referenced this issue Jan 16, 2025
Add RuntimeHints for GraylogExtendedLogFormatProperties,
StructuredLoggingJsonProperties and ElasticCommonSchemaProperties
properties.

Add BeanFactoryInitializationAotProcessor to register RuntimeHints
for a custom StructuredLoggingJsonMembersCustomizer.

See spring-projectsgh-43861

Signed-off-by: Dmytro Nosan <[email protected]>
@philwebb
Copy link
Member

Closing in favor of PR #43862. Thanks @nosan!

@philwebb philwebb closed this as not planned Won't fix, can't repro, duplicate, stale Jan 16, 2025
@philwebb philwebb added status: superseded An issue that has been superseded by another and removed type: bug A general bug labels Jan 16, 2025
@philwebb philwebb removed this from the 3.4.x milestone Jan 16, 2025
nosan added a commit to nosan/spring-boot that referenced this issue Jan 17, 2025
Add RuntimeHints for GraylogExtendedLogFormatProperties,
StructuredLoggingJsonProperties and ElasticCommonSchemaProperties
properties.

Add BeanFactoryInitializationAotProcessor to register RuntimeHints
for a custom StructuredLoggingJsonMembersCustomizer.

See spring-projectsgh-43861

Signed-off-by: Dmytro Nosan <[email protected]>
nosan added a commit to nosan/spring-boot that referenced this issue Jan 20, 2025
Add RuntimeHints for GraylogExtendedLogFormatProperties,
StructuredLoggingJsonProperties and ElasticCommonSchemaProperties
properties.

Add BeanFactoryInitializationAotProcessor to register RuntimeHints
for a custom StructuredLoggingJsonMembersCustomizer.

Closes spring-projectsgh-43861

Signed-off-by: Dmytro Nosan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: superseded An issue that has been superseded by another
Projects
None yet
Development

No branches or pull requests

5 participants