Skip to content

Honor spring.cloud.config.watch.enabled on Log4j2EventListener - #4252

Open
AzazelSensei wants to merge 1 commit into
apache:2.xfrom
AzazelSensei:fix-4244-event-listener-condition
Open

Honor spring.cloud.config.watch.enabled on Log4j2EventListener#4252
AzazelSensei wants to merge 1 commit into
apache:2.xfrom
AzazelSensei:fix-4244-event-listener-condition

Conversation

@AzazelSensei

Copy link
Copy Markdown

Log4j2EventListener is also created from spring.factories, so @ConditionalOnProperty never applies and spring.cloud.config.watch.enabled=false does nothing.

I check that property in onApplicationEvent (via EnvironmentAware or the event source context). Explicit false skips the reload. Missing or true keeps the old behavior.

Fixes #4244

Checklist

  • Base your changes on 2.x branch if you are targeting Log4j 2; use main otherwise
  • ./mvnw verify succeeds (the build instructions)
  • Non-trivial changes contain an entry file in the src/changelog/.2.x.x directory
  • Tests are provided

spring.factories constructs the listener outside the bean factory, so
@ConditionalOnProperty never applies. Check the property in
onApplicationEvent as well.

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

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

Log4j2EventListener's @ConditionalOnProperty has no effect - the listener always runs

1 participant