ramanathan1504 opened a new issue, #4244:
URL: https://github.com/apache/logging-log4j2/issues/4244
## Description
`Log4j2EventListener` carries
`@ConditionalOnProperty("spring.cloud.config.watch.enabled")`, but always runs.
It is registered twice:
- as `@Component` — the condition applies here
- in `META-INF/spring.factories` (line 17) as an `ApplicationListener` — the
condition **cannot** apply, because `SpringApplication` instantiates these
directly during startup, with no bean definition for a condition to suppress
So `spring.cloud.config.watch.enabled=false` disables nothing, and
`EnvironmentChangeEvent` still reaches `WatchEventManager.publishEvent()`.
## Configuration
**Version:** 2.x @ `04c93c1d33` · **JDK:** 21 · **Spring Boot:** 3.4.3
## Logs
Captured with the property set to `false`, `monitorInterval` at 300s:
```
RELOADED - the refresh event drove the reload, 298 seconds before
the monitorInterval would have
```
Reloading 298s ahead of the interval means the event drove it, not the timer.
## Reproduction
Run an app with `log4j-spring-cloud-config-client` and a Config server, set
`-Dspring.cloud.config.watch.enabled=false`, then publish an
`EnvironmentChangeEvent` (e.g. POST `/actuator/refresh`). Log4j reconfigures
anyway.
## Suggested fix
Check the property inside `onApplicationEvent` against the `Environment` —
smallest change, and keeps the documented switch meaningful. Alternatively drop
`@ConditionalOnProperty` so the source stops promising a switch that does not
exist.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]