What is the issue with the runtime discovery algorithm of Apache Commons Logging

后端 未结 4 1344
隐瞒了意图╮
隐瞒了意图╮ 2020-12-02 05:44

Dave Syer (SpringSource) writes in his blog:

Unfortunately, the worst thing about commons-logging, and what has made it unpopular with new tools, is a

4条回答
  •  死守一世寂寞
    2020-12-02 06:02

    Commons logging is a light weight logging facade which is placed on top of the heavy weight logging API be that log4j, java.util.logging or another supported logging API.

    The discovery algorithm is what commons logging uses to determine what logging API you use at runtime so it can direct log calls through its API to the underlying logging API. The benefit of this is that if you wanted to create a library that does logging, you do not want to tie down users of your library to any particular heavy weight logging system. Callers of your code can configure logging via log4j, java.util.logging etc. and commons logging will forward to that API at runtime.

    Common gripes for commons logging:

    • Even though you don't use it, a library you depend on might so you have to include it in your classpath anyway.
    • Runs the discovery algorithm for each classloader you want to do logging in, which can produce unwanted results so make sure you put commons-logging.jar in the right classloader.
    • Greater complexity than the underlying logging framework.
    • Less features that underlying logging framework.

    A perceived greater complexity as well as unpredictability in complex classpath hierarchies without any perceived benefits make users of commons-logging agitated. Given also that this choice may be forced on you does not make users sympathetic. See this article for a compelling argument against using commons-logging.

提交回复
热议问题