2013-07-18 59 views
0

這裏是我的服務器我看到當前的記錄:如何包括log4j配置日期

12:40:10,190 | INFO | -549263035-19951 | ServiceImpl | Upload started 
12:40:12,912 | INFO | -549263035-19960 | ServiceImpl | Upload started 
12:40:12,915 | INFO | -549263035-19958 | ServiceImpl | Upload started 

My application is using log4j to implement logging. here is the log4j.properties file which is sitting inside META-INF. 

log4j.rootCategory=DEBUG, O 
log4j.appender.O=org.apache.log4j.ConsoleAppender 
log4j.appender.O.layout=org.apache.log4j.PatternLayout 
log4j.appender.O.layout.ConversionPattern=[%d{ISO8601}]%5p%6.6r[%t]%x - %C.%M(%F:%L) - %m%n 


As we can clearly see, current logging has the time information for every event. I wanted to know if there is a way I could make some changes in this properties file or elsewhere to include the full timestamp i.e. Date and time both. 

類似: 2013年7月18日12時40分十二秒| INFO | -549263035-19958 | ServiceImpl |開始上傳

Thanks for suggestion. 
+0

我有感覺,你的記錄器消息使用的不是你發佈的佈局,你能否以某種方式改變你的模式(例如刪除[%d {ISO8601}]),並確保你的記錄輸出會改變。 – nkukhar

+0

我經歷了文檔,看起來你是對的,我的日誌不使用這種佈局。因爲%d後跟ISO8601也應該記錄日期。我假設我部署此應用程序的服務器使用的是優先於它的不同日誌記錄方案。但我不知道如何解決這個問題。 – Ashish

+0

thanx爲您的輸入 – Ashish

回答

0

找到我的答案了。 此應用程序已部署在Servicemix容器中。在servicemix的安裝目錄裏面,我發現了這個配置文件。 「/usr/local/servicemix/etc/org.ops4j.pax.logging.cfg」。

在這個文件裏面,有一個使用%d [ABSOLUTE]作爲轉換模式的SiftingAppender。因此,基本上,在servicemix下部署的每個bundle都將使用此「篩選器」屬性。我剛剛從這個配置文件中刪除了[ABSOLUTE],並開始在我的日誌中獲取日期。