use of org.apache.log4j.PropertyConfigurator in project apex-core by apache.
the class LoggerUtil method addAppender.
/**
* Adds Logger Appender
* @param name Appender name
* @param properties Appender properties
* @return True if the appender has been added successfully
*/
public static boolean addAppender(String name, Properties properties) {
if (getAppendersNames().contains(name)) {
logger.warn("A logger appender with the name '{}' exists. Cannot add a new logger appender with the same name", name);
} else {
try {
Method method = PropertyConfigurator.class.getDeclaredMethod("parseAppender", Properties.class, String.class);
method.setAccessible(true);
Appender appender = (Appender) method.invoke(new PropertyConfigurator(), properties, name);
if (appender == null) {
logger.warn("Cannot add a new logger appender. Name: {}, Properties: {}", name, properties);
} else {
LogManager.getRootLogger().addAppender(appender);
return true;
}
} catch (Exception ex) {
logger.warn("Cannot add a new logger appender. Name: {}, Properties: {}", name, properties, ex);
}
}
return false;
}
use of org.apache.log4j.PropertyConfigurator in project jena by apache.
the class TestMemDriverWithLogging method afterClassResetLogging.
@AfterClass
public static void afterClassResetLogging() {
// Unfortunately, this code "knows" how log4j was set up in testing
// Thsi is fragile.
URL configURL = Loader.getResource("log4j.properties");
new PropertyConfigurator().doConfigure(configURL, LogManager.getLoggerRepository());
}
Aggregations