What are the vantagens
and desvantagens
of each? Can they be usados simultaneamente
in the same project?
What are the vantagens
and desvantagens
of each? Can they be usados simultaneamente
in the same project?
The advantage of SLF4J
is that it is an abstraction of many of the existing log frameworks, allowing the creation of a program , frameworks, and libraries regardless of the actual log implementation to be used.
This is important, for example, because the same application can be deployed on different application servers that use different logging mechanisms. In addition, there is a serious problem when different libraries or classes used in the same project use different logging mechanisms. Imagine using an MVC framework that uses java.util.logging
, a persistence framework that uses Apache Commons Logging
, and another reporting framework that uses Log4j. The API for each of these is different and you may encounter class conflicts and configuration.
SLF4J
can work together with Log4j
without any difficulty, as well as being able to use other implementations.
SLF4J
, in this case), then the developer or the end-user is free to use the library of his choice, without compromising development because of of a third party component.
The only context I can see where it would be advantageous to use only Log4j would be in the case of a project without external dependencies, as there would be no reason to abstract the logging mechanism.