log4j和slf4j

来源:互联网 发布:信誉好的淘宝高仿nike 编辑:程序博客网 时间:2024/06/05 19:08

You can think of slf4j as a big "interface" that needs an implementation. So, just using slf4j standalone will not get you any logging (aside from using slf4j-simple, which is a bundled mini implementation that can only log to console).

So, what can you use as an implementation? log4j is one example. Why would you want to use slf4j then? Because you can use this one interface and then swap implementations if needed.

What are the available backends that can be used?

  • log4j
  • java.util.logging
  • commons logging
  • logback

I'd suggest using Logback. It's a better log4j.