Any reason for a new project to use log4j instead of Logback? [closed]

强颜欢笑 提交于 2019-12-04 03:11:04

问题


I know that the common opinion is that Logback > log4j. Still, is there anything log4j does better than Logback? Any reason to use log4j over logback? How about the fact it only has 60 questions on stack overflow, so I presume a much smaller user base?


回答1:


Take a look at official opinion. log4j isn't under active development anymore, and since logback is being developed ground up by the same author as log4j, Ceki Gülcü, to correct some mistakes made in log4j's development, you can be pretty sure that using logback isn't a bad idea.




回答2:


No matter what logging backend you choose, I suggest using slf4j as a frontend to it. It may seem like overkill, but in these times of dependency injection and abstraction, having a simple layer between you and the logging impl isn't so crazy.

As noted by Ceki, Logback's public API actually is slf4j, so if you choose Logback and use it in the recommended way, you are already using slf4j.



来源:https://stackoverflow.com/questions/4311086/any-reason-for-a-new-project-to-use-log4j-instead-of-logback

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!