de.intarsys.tools.logging.CompositeHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of isrt Show documentation
Show all versions of isrt Show documentation
The basic runtime tools and interfaces for intarsys components.
package de.intarsys.tools.logging;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Handler;
import java.util.logging.LogRecord;
/**
* A Java logging {@link Handler} that forwards to a collection of other
* {@link Handler} instances.
*
*/
public class CompositeHandler extends Handler {
private List handlers = new ArrayList();
public void addHandler(Handler handler) {
handlers.add(handler);
}
@Override
public void close() throws SecurityException {
for (Handler handler : handlers) {
handler.close();
}
}
@Override
public void flush() {
for (Handler handler : handlers) {
handler.flush();
}
}
public Handler[] getHandlers() {
return handlers.toArray(new Handler[handlers.size()]);
}
@Override
public void publish(LogRecord record) {
for (Handler handler : handlers) {
handler.publish(record);
}
}
public void removeHandler(Handler handler) {
handlers.remove(handler);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy