slf4japache-commons-logging

CommonsLogger equivalent for slf4j


We are migrating from commons-logging to slf4j.

We are using org.apache.fop.apps.Driver class to generate PDF files. Now, setLogger() method of Driver class takes org.apache.avalon.framework.logger.Logger as an argument.

CommonsLogger method is provided in org.apache.avalon.framework.logger package that converts commons-logging logger into org.apache.avalon.framework.logger.Logger.

Please find below sample code:

org.apache.fop.apps.Driver driver = new Driver();
driver.setLogger(new CommonsLogger(logger, getClass().getName()));

Now, what shall be the replacement for slf4j logger?

Best, I can guess is using NullLogger() instead of CommonsLogger(). Please tell me if any better solution available.


Solution

  • I suggest you create an implementation of org.apache.avalon.framework.logger.Logger that will take an SLF4J logger. Similar to this one here - https://svn.ametys.org/trunk/runtime/trunk/main/kernel/src/org/ametys/runtime/util/SLF4JLogger.java