Apache Commons Logging的运行时发现算法有什么问题 [英] What is the issue with the runtime discovery algorithm of Apache Commons Logging

查看:128
本文介绍了Apache Commons Logging的运行时发现算法有什么问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Dave Syer(SpringSource)写入他的博客:

Dave Syer (SpringSource) writes in his blog:


不幸的是,关于commons-logging的最糟糕的事情,以及使它不受新工具欢迎的因素,也是运行时发现算法。

Unfortunately, the worst thing about commons-logging, and what has made it unpopular with new tools, is also the runtime discovery algorithm.

为什么?它的运行时发现算法有什么问题?表现?

Why? What is the issue with its runtime discovery algorithm? Performance?

推荐答案


为什么?它的运行时发现算法有什么问题?表现?

Why? What is the issue with its runtime discovery algorithm? Performance?

不,这不是表现,它是 classloader痛苦。 JCL发现过程依赖于类加载器黑客在运行时查找日志框架,但是这种机制导致许多问题,包括意外行为,难以调试类加载问题导致复杂性增加。 Ceki(Log4J,SLF4J和Logback的作者)在采用公共日志记录之前再次思考API (也提到了JCL观察到的内存泄漏问题)。

No, it's not performance, it's classloader pain. JCL discovery process relies on classloader hacks to find the logging framework at runtime but this mechanism leads to numerous problems including unexpected behavior, hard to debug classloading problems resulting in increased complexity. This is nicely captured by Ceki (the author of Log4J, SLF4J and Logback) in Think again before adopting the commons-logging API (which also mentions memory leaks problems observed with JCL).

这就是创建使用静态绑定的SLF4J的原因。

And this is why SLF4J, which uses static bindings, has been created.

Ceki是SLF4J的作者,你可能会认为他的文章有偏见,但相信我,他们不是,他提供了很多参考资料(证据)来证明他的积分。

Ceki being the author of SLF4J, you might think his articles are biased but, believe me, they are not and he is providing lots of references (evidences) to prove his point.

总结:


  • 是的,JCL是众所周知的

  • 如果你想使用日志门面(并非所有项目都需要),请使用SLF4J。

  • SLF4J为仍然使用像Spring这样的JCL的框架提供了一个JCL-to-SLF4J桥:(

  • 我发现Logback是Log4J的继承者,是一个优秀的日志记录实现。

  • Logback本机实现了SLF4J API。这意味着如果您使用的是Logback,那么您实际上正在使用SLF4J API。

  • Yes, JCL is known to be broken, better stay away from it.
  • If you want to use a logging facade (not all projects need that), use SLF4J.
  • SLF4J provides a JCL-to-SLF4J bridge for frameworks still using JCL like Spring :(
  • I find Logback, Log4J's successor, to be a superior logging implementation.
  • Logback natively implements the SLF4J API. This means that if you are using Logback, you are actually using the SLF4J API.
  • Commons Logging was my fault
  • Think again before adopting the commons-logging API
  • SLF4J Vs JCL / Dynamic Binding Vs Static Binding

这篇关于Apache Commons Logging的运行时发现算法有什么问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆