“線上出Bug了矮冬。秕硝。⌒牛”
“快看看日志贩猎,哪里出問題了熊户。。吭服∪卤ぃ”
日志記錄是軟件開發(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是Apache的一個開源項目打瘪,通過使用Log4j友鼻,我們可以控制日志信息輸送的目的地是控制臺傻昙、文件、GUI組件彩扔,甚至是套接口服務(wù)器妆档、NT的事件記錄器、UNIX Syslog守護進程等虫碉。
Logback是由log4j創(chuàng)始人設(shè)計的又一個開源日志組件贾惦。logback當(dāng)前分成三個模塊: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)贺嫂。