I\'m working on a JSF-Project with Primefaces on Websphere Application Server. Since Primefaces uses java.util.logging, I\'m using the jul-to-slf4j Bridge to capture the Primefa
I found a solution using java.util.logging.Filter
, the filter just checks, if the name of the logger starts with org.primefaces
:
For this Solution, one has to set the SLF4JBridgeHandler and the Filter programmatically, setting it with the logging.properties file wont work.
Also, one hast to create the SLF4JBridgeHandler himself, due what is afaik a Bug, the SLF4JBridgeHandler dosn't respect the Filter out of the box.
SLF4JBridgeHandler slf4jBridgeHandler = new SLF4JBridgeHandler(){
@Override
public void publish(LogRecord record) {
if (getFilter() != null && !getFilter().isLoggable(record)) {
return;
}
super.publish(record);
}
};
Filter filter = new Filter() {
@Override
public boolean isLoggable(LogRecord record) {
String loggerName = record.getLoggerName();
boolean loggable = loggerName != null && (loggerName.startsWith("org.primefaces"));
return loggable;
}
};
slf4jBridgeHandler.setFilter(filter);
java.util.logging.LogManager.getLogManager().getLogger("").addHandler(slf4jBridgeHandler);
Do not call SLF4JBridgeHandler.removeHandlersForRootLogger()
since that will remove every other Handler that was set by Websphere!