Hi all,

the idea is to have to enable the user to change the config from the UI of the 
web applications (without accessing the server).
I would like to know if it is possible to have both a configuration file 
(automatically reloaded using monitorInterval)  for Log4J2 for the default 
usage of the application and the configuration being modified programatically 
the fly when investigating issue. How to implement that?
On way could be to write on the fly the configuration file when it is set to be 
reloaded automatically but is there an another way that would pause the reading 
from the config file and use the API?

I already asked this question on logback mailing list and I got a solution 
using properties in the configuration file and this piece of code from java 
side to force LogBack to reload the configuration file (that is not modified).
On Java side the code snippet for LogBack is
    LoggerContext loggerContext = (LoggerContext) 
LoggerFactory.getILoggerFactory();
    loggerContext.reset();                   
    ContextInitializer ci = newContextInitializer(loggerContext);
    ci.autoConfig();

I've tried with Log4j2:
        Properties p = new Properties(System.getProperties());
        p.setProperty("MyProp", "MyPropValue");
        System.setProperties(p);

        LogManager.resetConfiguration();
but it wasn't effective. What is wrong here?

Thanks,

Xavier.

Reply via email to