Custom logger is logging messages of all levels

Solution Verified - Updated -


  • JBoss Enterprise Application Platform (EAP) 6.x


  • I installed a custom logger, but it is logging all messages regardless of their logging level. I set the handler's log level to INFO, but it still prints all messages.


You need to call isLoggable() from your publish() method. Something like this:

public void publish(final LogRecord logRecord) {
  if(logRecord != null && isLoggable(logRecord)) {
    //Write out the log message here

Root Cause

If you'll look at the source for org.jboss.logmanager.handlers.ConsoleHandler, you'll see that it extends OutputStreamHandler which extends WriterHandler which extends ExtHandler, which finally extends java.util.logging.Handler. ExtHandler implements publish() for all subclasses, and subclasses of ExtHandler are expected to implement doPublish(). Though ConsoleAppender and WriterAppender (which actually implements doPublish()) don't call isLoggable(), ExtHandler already does this for them in its publish() method. This means that all handlers used by JBoss all call isLoggable() in their publish() method.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.