mardi 5 juillet 2016

How to use extended SLF4J with Logback

We have extended SLF4J's Logger API and created AppLogger interface. We have to do this for certain need which I cannot disclose here. Now, we want to use this extended logger with LogBack framework. I am not able to find any mechanism how to make it work. Direct usage is throwing ClassCastException (this is obvious because it is expecting a class with name Logger and getting AppLogger).

I am able to make this extended interface work with Log4J 1.x and Log4J 2.x by writing a bridge implementation and providing custom StaticBinder classes. For LogBack, this bridge class (StaticBinder) is part of logback-classic JAR file, so I am not sure how to write my own binder and bridge LogBack.

The AppLogger interface looks like:

public interface AppLogger extends org.slf4j.Logger {
    public void myOwnMethod(String message, Object... args);
}

Appreciate if anyone provide any idea.

Aucun commentaire:

Enregistrer un commentaire