log4j日誌介紹

2021-08-19 14:44:33 字數 1130 閱讀 9692

log4j.rootlogger=debug, stdout,console,file

# console output...

.stdout=org.apache

.stdout

.layout=org.apache

.log4j.patternlayout

.console=org.apache

.console

.threshold=info

.console

.layout=org.apache

.log4j.patternlayout

.console

.layout

.conversionpattern=%d [%5p] -%f(%l) -%m%n

.file=org.apache

.file

.file

.file=logs/log.log

.file

.threshold=info

.file

.layout=org.apache

.log4j.patternlayout

.file

.layout

.conversionpattern=%d [%5p] -%f(%l) -%m%n

.file

.maxfilesize=10mb

trace: 是追蹤,就是程式推進以下,你就可以寫個trace輸出,

所以trace應該會特別多,不過沒關係,我們可以設定最低日誌級別不讓他輸出。

debug: 除錯麼,我一般就只用這個作為最低級別,trace壓根不用。

是在沒辦法就用eclipse或者idea的debug功能就好了麼。

info: 輸出一下你感興趣的或者重要的資訊,這個用的最多了。

warn: 有些資訊不是錯誤資訊,但是也要給程式設計師的一些提示,

類似於eclipse中**的驗證不是有error 和warn

(不算錯誤但是也請注意,比如以下depressed的方法)。

error: 錯誤資訊。用的也比較多。

fatal: 級別比較高了。重大錯誤,這種級別你可以直接停止程式了,

是不應該出現的錯誤麼!

log4j日誌系統 Log4j

1.1 log4j的三大核心元件 1.2 loggers 記錄器 1.4 layouts 布局 org.apache.log4j.htmllayout 以html 形式布局 org.apache.log4j.patternlayout 可以靈活地指定布局模式 org.apache.log4j.lay...

log4j記錄不同的日誌 Log4j 日誌記錄方法

logger類具有處理日誌記錄活動的方法。我們可以使用兩個靜態方法建立logger類的例項 public static logger getrootlogger public static logger getlogger string name 第乙個方法返回沒有名稱的根日誌記錄器。第二個方法按名...

Log4j 日誌級別

日誌記錄器 logger 是日誌處理的核心元件。log4j具有5種正常級別 level 日誌記錄器 logger 的可用級別level 不包括自定義級別 level static level debug debug level指出細粒度資訊事件對除錯應用程式是非常有幫助的。static level ...