Skip to content

fix: Restore Backward Compatibility with Spring Boot Reconfiguration #3773

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

Merged
merged 3 commits into from
Jun 28, 2025

Conversation

ppkarwasz
Copy link
Contributor

@ppkarwasz ppkarwasz commented Jun 21, 2025

Although Spring Boot never directly starts a LoggerContext, its logging system — including our Log4j2SpringBootLoggingSystem and equivalents in Spring Boot 2.x and 3.x — has consistently used LoggerContext.start(Configuration) for reconfiguration.

This use case was not taken into consideration in #2614, causing a regression for Spring Boot users.

To maintain backward compatibility with these usages, start(Configuration) now falls back to reconfigure(Configuration) if the context is already started.

Closes #3770

Add test verifying expected behavior of `LoggerContext.start(Configuration)` to ensure backward compatibility:

- The configuration must always be replaced, even if the context has already started.
- Only the first configuration should register the shutdown hook.
Although Spring Boot never directly starts a `LoggerContext`, its logging system — including our `Log4j2SpringBootLoggingSystem` and equivalents in Spring Boot 2.x and 3.x — has consistently used `LoggerContext.start(Configuration)` for reconfiguration.

To maintain backward compatibility with these usages, `start(Configuration)` now falls back to `reconfigure(Configuration)` if the context is already started.

Closes #3770
@ppkarwasz ppkarwasz moved this from To triage to In review in Log4j bug tracker Jun 21, 2025
Copy link
Member

@vy vy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ppkarwasz, thanks for taking care of this. 🙏

Is #2614 where we removed the old behaviour? If so, would you mind referring to it in the ticket description, please?

@ppkarwasz ppkarwasz enabled auto-merge (squash) June 28, 2025 07:10
@ppkarwasz ppkarwasz merged commit 9b66389 into 2.x Jun 28, 2025
7 checks passed
@ppkarwasz ppkarwasz deleted the fix/3770_LoggerContext_start branch June 28, 2025 07:26
@github-project-automation github-project-automation bot moved this from In review to Done in Log4j bug tracker Jun 28, 2025
ppkarwasz added a commit that referenced this pull request Jul 5, 2025
…3773)

### feat: add tests for `LoggerContext.start` behavior

Add test verifying expected behavior of `LoggerContext.start(Configuration)` to ensure backward compatibility:

- The configuration must always be replaced, even if the context has already started.
- Only the first configuration should register the shutdown hook.

### fix: Restore Backward Compatibility with Spring Boot Reconfiguration

Although Spring Boot never directly starts a `LoggerContext`, its logging system — including our `Log4j2SpringBootLoggingSystem` and equivalents in Spring Boot 2.x and 3.x — has consistently used `LoggerContext.start(Configuration)` for reconfiguration.

This use case was not taken into consideration in #2614, causing a regression for Spring Boot users.

To maintain backward compatibility with these usages, `start(Configuration)` now falls back to `reconfigure(Configuration)` if the context is already started.

Closes #3770
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

No Spring Boot logging output with Log4J 2.25.0
2 participants