關於如何挑選 Logging 函式庫，SpringFramework 文件有一段簡單的說明比較。
Logging is a very important dependency for Spring because a) it is the only mandatory external dependency, b) everyone likes to see some output from the tools they are using, and c) Spring integrates with lots of other tools all of which have also made a choice of logging dependency. One of the goals of an application developer is often to have unified logging configured in a central place for the whole application, including all external components. This is more difficult than it might have been since there are so many choices of logging framework.
Not Using Commons Logging
＊不建議使用 Apache Jakarta Common Logging (JCL)
Unfortunately, the runtime discovery algorithm in commons-logging, while convenient for the end-user, is problematic. If we could turn back the clock and start Spring now as a new project it would use a different logging dependency. The first choice would probably be the Simple Logging Facade for Java (SLF4J), which is also used by a lot of other tools that people use with Spring inside their applications.
SLF4J is a cleaner dependency and more efficient at runtime than commons-logging because it uses compile-time bindings instead of runtime discovery of the other logging frameworks it integrates. This also means that you have to be more explicit about what you want to happen at runtime, and declare it or configure it accordingly. SLF4J provides bindings to many common logging frameworks, so you can usually choose one that you already use, and bind to that for configuration and management.
SLF4J provides bindings to many common logging frameworks, including JCL, and it also does the reverse: bridges between other logging frameworks and itself. So to use SLF4J with Spring you need to replace the commons-logging dependency with the SLF4J-JCL bridge. Once you have done that then logging calls from within Spring will be translated into logging calls to the SLF4J API, so if other libraries in your application use that API, then you have a single place to configure and manage logging.
Many people use Log4j as a logging framework for configuration and management purposes. It's efficient and well-established, and in fact it's what we use at runtime when we build and test Spring. Spring also provides some utilities for configuring and initializing Log4j, so it has an optional compile-time dependency on Log4j in some modules.
- NetBeans IDE 字型美化 on Ubuntu Linux
- 利用 IntelliJ IDEA Community Edition (Free) 輕鬆開發 Gra...
- 解決 Ubuntu 13.10 音量圖示消失的問題
- Review: Functional Programming for Java Developers...
- O'Reilly Atlas - 來自 O'Reilly 的線上免費學習資源，結合閱讀與出版
- Ubuntu Linux apt-get 徹底移除套件（purge）的使用方式
- NetBeans IDE 開發工具效能調校（記憶體設定篇）
- Choosing Logging Framework for Java Projects
- Compile and Run GWT project with Gradle build tool...
- ▼ 十一月 (9)
- ► 2012 (181)
- ► 2011 (197)
- ► 2009 (111)
- ► 2008 (241)