Hi, im wondering if i could have some help with migrating from log4j1 to log4j2 
please?
Im trying to update gerrit to log4j2 but am stuck on some things. [1]
1. How do i migrate from 
PropertyConfigurator.configure(Loader.getResource(LOG_CONFIGURATION)); to 
something log4j2 compatible please?
Im trying to migrate all the way without trying to use log4j1 compatible api 
log4j2. (Though im still pulling it in i am trying not to use it).
I found doing something like
    String path = System.getProperty(JAVA_OPTIONS_LOG_CONFIG);    if 
(Strings.isNullOrEmpty(path)) {      ConfigurationSource source = 
ConfigurationSource.fromResource(LOG_CONFIGURATION, null);      
Configurator.initialize(null, source);    } else {      URL in = new URL(path); 
     Configurator.initialize((String) null, null, in.toURI());    }
could work but then it wont reload the configuation without restarting the 
configuation as new (ie gets rid of everything). which .reconfigure() does.
Im trying to reset log levels to null so that we can reload the configuation 
but reconfigure gets rid of everything thus causing problems if you used java 
to add appenders or anything else. see [2]
Also how would i migrate from using removeAllAppenders to log4j2 compatible 
code please?
[1] https://gerrit-review.googlesource.com/#/c/gerrit/+/142811/
[2] 
https://gerrit-review.googlesource.com/#/c/gerrit/+/142811/46/java/com/google/gerrit/sshd/commands/SetLoggingLevelCommand.java
 

Reply via email to