use of org.apache.logging.log4j.core.appender.routing.RoutingAppender in project ignite by apache.
the class Log4J2Logger method fileName.
/** {@inheritDoc} */
@Nullable
@Override
public String fileName() {
for (Logger log = impl; log != null; log = log.getParent()) {
for (Appender a : log.getAppenders().values()) {
if (a instanceof FileAppender)
return ((FileAppender) a).getFileName();
if (a instanceof RollingFileAppender)
return ((RollingFileAppender) a).getFileName();
if (a instanceof RoutingAppender) {
try {
RoutingAppender routing = (RoutingAppender) a;
Field appsFiled = routing.getClass().getDeclaredField("appenders");
appsFiled.setAccessible(true);
Map<String, AppenderControl> appenders = (Map<String, AppenderControl>) appsFiled.get(routing);
for (AppenderControl control : appenders.values()) {
Appender innerApp = control.getAppender();
if (innerApp instanceof FileAppender)
return normilize(((FileAppender) innerApp).getFileName());
if (innerApp instanceof RollingFileAppender)
return normilize(((RollingFileAppender) innerApp).getFileName());
}
} catch (IllegalAccessException | NoSuchFieldException e) {
error("Failed to get file name (was the implementation of log4j2 changed?).", e);
}
}
}
}
return null;
}
Aggregations