for (Map.Entry<String, HandlerElement> entry : handlers.entrySet()) {
if (null == entry.getValue()) {
continue;
}
// solve handler element looking in cache
HandlerElement solved = this.solveHandlerElement(entry.getValue());
// create handler and add to logger
LogAbstractHandler handler = this.getHandlerInstance(solved);
if (null != handler) {
String nativeClassName = handler.getNativeClass().getName();
// update solved handler in cache
solved.setNativeClassName(nativeClassName);
this.addHandlerElementToCache(solved);
// update local handler in handlers Map
entry.getValue().setNativeClassName(nativeClassName);
// first need to close previouse handler
int closed = this.closeHandler(logger, nativeClassName);
_logger.log(Level.FINE, String.format("Closed %s handlers of class type '%s'", closed, solved.getClassName()));
try {
// open new handler
if (!handler.isOpen()) {
// Open handler
handler.open();
}
// add handler to logger
if (null != handler.getNative()) {
logger.addHandler(handler.getNative());
}
} catch (Throwable t) {
_logger.log(Level.WARNING,
String.format("Unable to open Handler: %s. Error Message was: %s",
entry.getKey(), t.getMessage()));
}
} else {
if (null != solved) {
_logger.log(Level.INFO,
"Handler not found for element: {0}",
solved.toString());
} else {
_logger.log(Level.INFO,
"Handler not found for element: {0}",
entry.getValue().toString());
}