use of org.apache.logging.log4j.core.config.AppenderControl in project logging-log4j2 by apache.
the class FailoverAppender method start.
@Override
public void start() {
final Map<String, Appender> map = config.getAppenders();
int errors = 0;
final Appender appender = map.get(primaryRef);
if (appender != null) {
primary = new AppenderControl(appender, null, null);
} else {
LOGGER.error("Unable to locate primary Appender " + primaryRef);
++errors;
}
for (final String name : failovers) {
final Appender foAppender = map.get(name);
if (foAppender != null) {
failoverAppenders.add(new AppenderControl(foAppender, null, null));
} else {
LOGGER.error("Failover appender " + name + " is not configured");
}
}
if (failoverAppenders.isEmpty()) {
LOGGER.error("No failover appenders are available");
++errors;
}
if (errors == 0) {
super.start();
}
}
use of org.apache.logging.log4j.core.config.AppenderControl in project logging-log4j2 by apache.
the class RewriteAppender method start.
@Override
public void start() {
for (final AppenderRef ref : appenderRefs) {
final String name = ref.getRef();
final Appender appender = config.getAppender(name);
if (appender != null) {
final Filter filter = appender instanceof AbstractAppender ? ((AbstractAppender) appender).getFilter() : null;
appenders.put(name, new AppenderControl(appender, ref.getLevel(), filter));
} else {
LOGGER.error("Appender " + ref + " cannot be located. Reference ignored");
}
}
super.start();
}
use of org.apache.logging.log4j.core.config.AppenderControl in project logging-log4j2 by apache.
the class LoggerConfigBenchmark method setup.
@Setup
public void setup() {
listAppender.start();
final AppenderControl control = new AppenderControl(listAppender, Level.ALL, null);
appenderSet.add(control);
}
use of org.apache.logging.log4j.core.config.AppenderControl in project logging-log4j2 by apache.
the class RoutesScriptAppenderTest method getListAppender.
private ListAppender getListAppender() {
final String key = "Service2";
final RoutingAppender routingAppender = getRoutingAppender();
Assert.assertTrue(routingAppender.isStarted());
final Map<String, AppenderControl> appenders = routingAppender.getAppenders();
final AppenderControl appenderControl = appenders.get(key);
assertNotNull("No appender control generated for '" + key + "'; appenders = " + appenders, appenderControl);
final ListAppender listAppender = (ListAppender) appenderControl.getAppender();
return listAppender;
}
use of org.apache.logging.log4j.core.config.AppenderControl in project hive by apache.
the class LlapWrappedAppender method setupAppenderIfRequired.
private void setupAppenderIfRequired(LogEvent event) {
if (appenderControl.get() == null) {
if (node.getType().getElementName().equalsIgnoreCase("appender")) {
for (final Node cnode : node.getChildren()) {
final Node appNode = new Node(cnode);
config.createConfiguration(appNode, event);
if (appNode.getObject() instanceof Appender) {
final Appender app = appNode.getObject();
app.start();
if (!(app instanceof RandomAccessFileAppender)) {
String message = "Cannot handle appenders other than " + RandomAccessFileAppender.class.getName() + ". Found: " + app.getClass().getName();
LOGGER.error(message);
throw new IllegalStateException(message);
}
realAppender.set(app);
appenderControl.set(new AppenderControl(app, null, null));
if (LOGGER.isDebugEnabled()) {
RandomAccessFileAppender raf = (RandomAccessFileAppender) app;
LOGGER.debug("Setup new appender to write to file: " + raf.getFileName() + ", appenderName=" + raf.getName() + ", appenderManagerName=" + raf.getManager().getName());
}
break;
}
}
if (appenderControl.get() == null) {
// Fail if mis-configured.
throw new RuntimeException(LlapWrappedAppender.class.getSimpleName() + "name=" + getName() + " unable to setup actual appender." + "Could not find child appender");
}
} else {
// Fail if mis-configured.
throw new RuntimeException(LlapWrappedAppender.class.getSimpleName() + "name=" + getName() + " unable to setup actual appender." + "Could not find child appender");
}
}
}
Aggregations