[logback-user] NOP logger issue/workaround

Rutger Saalmink rutgersaalmink at hotmail.com
Wed Sep 28 10:02:12 CEST 2011

Hi all,

Currently I am developing a logging class for weblogic, which functions as a tool for writing to a set of logfiles. Several types of external parties access this class (e.g. other classes, jars, services, etc), potentially concurrent calls. Conceptually it looks like this:

public class myClass{
  private static Logger loggerLog = LoggerFactory.getLogger(myClass.class);
  private static Logger logA = LoggerFactory.getLogger("my.logA");
  private static Logger logB = LoggerFactory.getLogger("my.logB");
  public static boolean logStringToA(final String strValue){
    loggerLog.info("Write String to log A.");
  public static boolean logNodeToB(final Node nodeValue){
    loggerLog.info("Write Node to log B.");
    // do some stuff with the Node

The problem is that SLF4j gets instantiated with NOP loggers on the first calls to the public methods, possibly due to:

To fix this problem I try to reload the logback configuration at run-time, explained in http://logback.qos.ch/manual/configuration.html#joranDirectly . However, this means that I will have to reinitialize the loggers in myClass (another call to LoggerFactory.getLogger()) before logging starts. But that would imply using some kind of reloading thread which checks for NOP loggers, which isn't that pretty. Also I would lose any logging calls going on in the meanwhile.

Anyone has a good idea on how to prevent SLF4j creating these NOP loggers, or a solution for the workaround?

Best regards,


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://qos.ch/pipermail/logback-user/attachments/20110928/3d282817/attachment.html>

More information about the Logback-user mailing list