1
votes

It is well known how to adapt code that uses log4j to slf4j and have the latter as main logger, including plugging implementations like LogBack as concrete application logger.

What about the opposite route? I have a large application that is using log4j everywhere, migrating it to slf4j would be very difficult, for instance I have many command line tools all having their own log4j config file.

Now I have to extend the application by using a small library that is sending log messages to the slf4j interface.

Is there a way to re-route all slf4j calls to the already existing log4j, so that, for example, I could rely on the existing application configuration to tune the logging behaviour of the new library too?

1

1 Answers

1
votes

Is there a way to re-route all slf4j calls to the already existing log4j?

slf4j-log4j12 module will serve your purpose. More about this module here.

Overall, you will need:

  • log4j (latest 1.2.17): for existing dependencies and re-routing
  • slf4j-api (latest 1.7.25): for new slf4j dependent libraries
  • slf4j-log4j12 (latest 1.7.25): for re-routing