import org.apache.log4j.LogManager; import org.apache.log4j.PropertyConfigurator; ... // reset la configuration existante LogManager.getLoggerRepository().resetConfiguration(); // application de notre configuration PropertyConfigurator.configure(url); ...
Javadocs from org.apache.log4j.Hierarchy class:
Reset all values contained in this hierarchy instance to their
default. This removes all appenders from all categories, sets
the level of all non-root categories to
sets their additivity flag to
true and sets the level
of the root logger to Level DEBUG. Moreover,
message disabling is set its default “off” value.
Existing categories are not removed. They are just reset.
This method should be used sparingly and with care as it will
block all logging until it is completed.