java - Logback native VS Logback via SLF4J -


i have gone through following article regarding logging frameworks available java: http://michaelandrews.typepad.com/the_technical_times/2011/04/java-logging-reconsidered.html

the author has mentioned using slf4j logback. how different using logback directly. wouldn't better if 1 uses logback directly rather going slf4j, since logback built on top of slf4j.

slf4j adding 0 overhead logback since interface implemented logback without additional layer.

you should use slf4j because...

  1. it enables switch away logback if ever need to
  2. it not cost anything, imports smaller ;)
  3. other people love using slf4j , hate using specific logging framework directly if ever release code wild.

the place you'd access logback directly while (re)configuring logging manually in application. need arises in case, working logback restricted single class or method.

as rule of thumb: libraries should use logging abstraction while applications define logging using, optionally accessing directly.


Comments