簡介

“線上出Bug了。。?!?/em>
“快看看日志,哪里出問題了。。?!?/em>


日志記錄是軟件開發(fā)不可缺少的部分,該文集將對日志做一些介紹。
我想提到日志, log4j 你一定知道,也許你在想,我還知道 logback,也知道 slf4j。

why logging

Inserting log statements into your code is a low-tech method for debugging it. It may also be the only way because debuggers are not always available or applicable. This is often the case for distributed applications.

On the other hand, some people argue that log statements pollute source code and decrease legibility. (We believe that the contrary is true). In the Java language where a preprocessor is not available, log statements increase the size of the code and reduce its speed, even when logging is turned off. Given that a reasonably sized application may contain thousands of log statements, speed is of particular importance.

Logback Project

Logback is intended as a successor to the popular log4j project, picking up where log4j leaves off.

Simple Logging Facade for Java (SLF4J)

The Simple Logging Facade for Java (SLF4J) serves as a simple facade or abstraction for various logging frameworks (e.g. java.util.logging, logback, log4j) allowing the end user to plug in the desired logging framework at deployment time.

LOG4J
LOGBack
SLF4J

Log4j是Apache的一個開源項目,通過使用Log4j,我們可以控制日志信息輸送的目的地是控制臺、文件、GUI組件,甚至是套接口服務(wù)器、NT的事件記錄器、UNIX Syslog守護進程等。

Logback是由log4j創(chuàng)始人設(shè)計的又一個開源日志組件。logback當前分成三個模塊:logback-core,logback- classic和logback-access。logback-core是其它兩個模塊的基礎(chǔ)模塊。logback-classic是log4j的一個 改良版本。此外logback-classic完整實現(xiàn)SLF4J API使你可以很方便地更換成其它日志系統(tǒng)如log4j或JDK14 Logging。logback-access訪問模塊與Servlet容器集成提供通過Http來訪問日志的功能。

SLF4J,即簡單日志門面(Simple Logging Facade for Java),不是具體的日志解決方案,它只服務(wù)于各種各樣的日志系統(tǒng)。按照官方的說法,SLF4J是一個用于日志系統(tǒng)的簡單Facade,允許最終用戶在部署其應(yīng)用時使用其所希望的日志系統(tǒng)。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容