-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fix reloading of the configuration from HTTP(S) #2941
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general I took the liberty of bumping some status logger messages to INFO
.
IMHO the INFO
level should be used for important events like:
- The start and stop of configurations,
- The start and stop of logger contexts,
- Whenever
Watcher#isModified
returns true, which triggers a reconfiguration.
The overall effect should be the following:
2024-09-10T17:57:04.161594820Z main INFO Starting configuration XmlConfiguration[location=http://localhost:8000/log4j2-file.xml, lastModified=2024-09-10T13:34:24Z]...
2024-09-10T17:57:04.161688451Z main INFO Start watching for changes to http://localhost:8000/log4j2-file.xml every 5 seconds
2024-09-10T17:57:04.162631305Z main INFO Configuration XmlConfiguration[location=http://localhost:8000/log4j2-file.xml, lastModified=2024-09-10T13:34:24Z] started.
2024-09-10T17:57:04.162821558Z main INFO Stopping configuration org.apache.logging.log4j.core.config.DefaultConfiguration@23d2a7e8...
2024-09-10T17:57:04.163001700Z main INFO Configuration org.apache.logging.log4j.core.config.DefaultConfiguration@23d2a7e8 stopped.
2024-09-10T17:57:49.186202317Z Log4j2-TF-2-Scheduled-1 INFO HTTP resource at http://localhost:8000/log4j2-file.xml was modified on 2024-09-10T17:57:44Z
2024-09-10T17:57:49.186810805Z Log4j2-TF-2-Scheduled-1 INFO Configuration source at http://localhost:8000/log4j2-file.xml was modified on 2024-09-10T17:57:44Z, previous modification was on 2024-09-10T13:34:24Z
2024-09-10T17:57:49.191685641Z Log4j2-TF-1-ConfigurationFileWatcher-2 INFO Starting configuration XmlConfiguration[location=http://localhost:8000/log4j2-file.xml, lastModified=2024-09-10T17:57:44Z]...
2024-09-10T17:57:49.191751282Z Log4j2-TF-1-ConfigurationFileWatcher-2 INFO Start watching for changes to http://localhost:8000/log4j2-file.xml every 5 seconds
2024-09-10T17:57:49.191891764Z Log4j2-TF-1-ConfigurationFileWatcher-2 INFO Configuration XmlConfiguration[location=http://localhost:8000/log4j2-file.xml, lastModified=2024-09-10T17:57:44Z] started.
2024-09-10T17:57:49.191969215Z Log4j2-TF-1-ConfigurationFileWatcher-2 INFO Stopping configuration XmlConfiguration[location=http://localhost:8000/log4j2-file.xml, lastModified=2024-09-10T13:34:24Z]...
2024-09-10T17:57:49.192266340Z Log4j2-TF-1-ConfigurationFileWatcher-2 INFO Configuration XmlConfiguration[location=http://localhost:8000/log4j2-file.xml, lastModified=2024-09-10T13:34:24Z] stopped.
log4j-core/src/main/java/org/apache/logging/log4j/core/config/HttpWatcher.java
Show resolved
Hide resolved
log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationSource.java
Outdated
Show resolved
Hide resolved
Accidentally I had to rewrite Since |
...j-core/src/main/java/org/apache/logging/log4j/core/filter/MutableThreadContextMapFilter.java
Outdated
Show resolved
Hide resolved
df6815a
to
cf73143
Compare
@vy, could you take a look at this? |
log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
Show resolved
Hide resolved
log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationSource.java
Outdated
Show resolved
Hide resolved
...j-core/src/main/java/org/apache/logging/log4j/core/filter/MutableThreadContextMapFilter.java
Show resolved
Hide resolved
...j-core/src/main/java/org/apache/logging/log4j/core/filter/MutableThreadContextMapFilter.java
Outdated
Show resolved
Hide resolved
log4j-core/src/main/java/org/apache/logging/log4j/core/util/WatchManager.java
Outdated
Show resolved
Hide resolved
Redirects all `ConfigurationSource` constructors to a single one. It performs also some null-analysis of the class.
Regarding the
If we look at the I have modified the 2 call sites that use the |
aab9235
to
2e4d0a8
Compare
While merging #2963, which was based on this PR, I accidentally merged part of these modifications. It is fixed now, but a force-push was necessary, sorry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you double-check that I didn't modify the behavior of
ConfigurationSource?
New canonical ctor and its usage LGTM, thanks!
I've dropped some more remarks.
log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationSource.java
Outdated
Show resolved
Hide resolved
log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationSource.java
Outdated
Show resolved
Hide resolved
The `HttpWatcher` didn't propagate the observed last modification time back to the configuration. As a result, each new configuration was already deprecated when it started and the reconfiguration process looped. Closes #2937 Rewrite Jetty tests using WireMock Closes #2813 Co-authored-by: Volkan Yazıcı <volkan@yazi.ci>
3598b6a
to
211c709
Compare
The
HttpWatcher
didn't propagate the observed last modification time back to the configuration.As a result, each new
Configuration
had the same last modification date as the first one and the reconfiguration process looped.Closes #2937