fix toString() method in configuration implementations (apache#3599)
Added toString implementation to AbstractConfiguration and removed from all derived classes.
Why? This makes debugging worse as we loosing information.
Why? This makes debugging worse as we loosing information.
hi @garydgregory , instead of AbstractConfiguration , shall I put my changes to all derived classes so that it can retain the additional info of subclasses.
Generated by gradle/develocity-actions
I am still -1 here: toString() is for debugging. If a call site needs a different view on the object, then it can call another method on that object or build that view (like a String) itself.
Hi @anindita-sarkarArray,
I discussed this with @garydgregory, and I agree that the toString() methods should remain unchanged to preserve a better debugging experience within IDEs.
Following the discussion in #3100, I also think it's a good idea to reduce verbosity in Log4j Core by default. With that in mind, I propose the following:
-
Downgrade the log level of the
INFOmessages I added inLoggerContextandAbstractConfigurationtoDEBUG, with one exception:- Keep the
INFOmessage at: https://github.com/apache/logging-log4j2/blob/422c385dc9450d4f620a23d84abe2d6a0aa5b9fb/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java#L328-L334
- Keep the
-
Add an
INFOmessage inLoggerContext.setConfiguration(Configuration)to notify users when a new configuration becomes active (i.e., after theupdateLoggers()call). The message could be formatted like:<logger_context_class_name>[name=<name>] is using <configuration_class_name>[location=<location>, lastModified=<last_modified>].
Let me know what you think.