Spring的文档中提到
[quote]the runtime discovery algorithm in commons-logging, while convenient for the end-user, is problematic. [/quote]
commons-logging的运行时发现算法有问题, 并推荐使用slf4j.
我很好奇,文档中所指的问题到底是运行效率问题, 还是想说commons-logging的依赖不够清晰, 或者是别的什么.
求指教啊.
[quote]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).
And this is why SLF4J, which uses static bindings, has been created.
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.
To sum up:
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.[/quote]
详见:[url]http://stackoverflow.com/questions/3222895/why-is-commons-logging-believed-to-be-unpopular[/url]
原来commons-logging用的class loader hacking是有问题的,难怪很久没有听到这玩意的广告了。