See the message from Ceki
"
Hello Niels,

I am following up on our discussion on stackoverflow.

Since logback-classic exposes its API via SLF4J, you would probably
want to extend org.slf4j.Logger. See the org.slf4j.ext package for
extension examples. The org.slf4j.ext.LoggerWrapper [1] class should
be particularly helpful. See also XLogger [2] and XLoggerFactory [3]
in the same package. The key here is to invoke LocationAwareLogger
when you can, i.e. when one of log4j, jul and logback is the
backend. That is as easy as:

class X {
   private static final String FQCN = X.class.getName();
   protected final boolean instanceofLAL;

   X() {
     if (logger instanceof LocationAwareLogger) {
       instanceofLAL = true;
     } else {
       instanceofLAL = false;
     }
   }

   void debug(Throwable t, String msg, ....) {
      if (instanceofLAL) {
         ((LocationAwareLogger) logger).log(null, FQCN ,
             LocationAwareLogger.TRACE_INT, msg, null, t);
       } else {
        logger.trace(msg, t);
      }
   }
"
It was years ago that I played around with it, so don't remember the
details, but I think this should be a possible way.
Niels
_______________________________________________
slf4j-user mailing list
slf4j-user@qos.ch
http://mailman.qos.ch/mailman/listinfo/slf4j-user

Reply via email to