Reputation: 2200
I read from the spring documentation that it requires commons logging dependency on the classpath and it was made compulsory. Alternatively it was suggested to use slf4j. What is the difference in using slf4j and commons logging. I am bit confused on which one to use. Please suggest the difference in using these two. Thanks in advance.
Upvotes: 0
Views: 232
Reputation: 653
slf4j is more efficient than commons logging. Moreover it acts as bridge- means you can change underlying logging provider with other than commons logging in future.
This link have good explaination. http://javarevisited.blogspot.in/2013/08/why-use-sl4j-over-log4j-for-logging-in.html
Upvotes: 0
Reputation: 400
Commons Logging and SLF4J are logging facades: you still need a real logging implementation (like log4j) If you are writing a library that will be used in someone else's system, then you should use a logging facade because you do not know which logging framework they will use. In this case use SLF4J (Commons Logging is older and has some classloader issues).
If you control the whole application and can dictate which logging framework to use, you are free to choose your own preference. My preferred solutions are (in order of preference):
Logback log4j JDK logging (in my opinion, a case of 'not invented here' by SUN)
Upvotes: 2