2012-07-10 15 views
0

我的應用程序運行在Jboss AS 7.1.1.final上。我需要將日誌寫入數據庫,所以我寫了一個自定義處理程序:public class DataSourceHandler extends java.util.logging.HandlerJboss AS 7自定義記錄器問題

一切工作正常,但我需要得到行號和名稱,這個日誌被稱爲從,也是如果有錯誤的堆棧跟蹤。

之前,我們升級到JBoss 7中,我們使用log4j的,我們設法用它來獲得:

org.apache.log4j.spi.LocationInfo locationInfo = new org.apache.log4j.spi.LocationInfo(event.getThrown(), event.getSourceClassName()); 
org.apache.log4j.spi.ThrowableInformation throwableInfo = new org.apache.log4j.spi.ThrowableInformation(event.getThrown()); 

if (locationInfo != null) { 
    fileName = locationInfo.getFileName(); 
    lineNumber = locationInfo.getLineNumber(); 
} 
if (throwableInfo != null) { 
    String[] exceptionArray = throwableInfo.getThrowableStrRep(); 
    for (String line : exceptionArray) { 
     exceptionBuffer.append(line).append(NEW_LINE); 
} 
info = extractInfo(exceptionBuffer); 
} 

我怎麼能現在做嗎?

回答