-1

I would like to know the interoperability of log4j with other frameworks. For example, if I want to shift to other logging framework from log4j in future, what will be the limitations.

Also, If I use log4j over slf4j, will it provide me the flexibility of changing the underlying logging framework?

Ultimately, my question is shall I use log4j over slf4j or just log4j by itself for logging with flexibility of changing it in future?

kittu
  • 6,662
  • 21
  • 91
  • 185

2 Answers2

3

You need to understand the purpose of SLF4J. SLF4J in actuality uses other frameworks like log4j, java logging or logback. SLF4J works through bindings to actually delegate the logging calls to the other libraries behind the scenes.

You can have a look at this

Why not use java.util.logging?

to make more sense of these libraries. The author of both log4j and SLF4j is answering this question.

You can find more insight from his answers as well those can be found under his profile.

Community
  • 1
  • 1
muasif80
  • 5,586
  • 4
  • 32
  • 45
1

Ultimately, we can't answer that for you. You need to make up your own mind, based on the short and long term requirements of the application you are building. For example,

  • If it is a simple system with a short lifetime, then it probably doesn't matter.

  • If it is a long term system that may need to evolve over time, then using a facade like slf4j has distinct long term advantages.

  • If it is a library that is designed to be widely reusable, then you need to consider the target "eco-system". But slf4j is highly advisable.

But before you decide you need to understand the purpose of the different technologies; particularly the real purpose of slf4j.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216