2013-11-20 106 views
0

我想從日誌解析器生成html輸出,有可能嗎?如何直接解析log4j格式的日誌文件。它期望列標題能夠獲取每行的內容。目前我手動添加少數列標題以獲取select子句中的行內容。是否可以在不添加新行的情況下閱讀內容?可以從微軟日誌解析器獲得html輸出嗎?

我有很多以下類型的行,我想處理一些報告。

2013-11-06 16:30:14,019 INFO [com.taliantsoftware.flash.FlashRemotingServerProxy] |qatester|18|com.taliantsoftware.claims.ClaimService.retrieveClaimParticipationForCustomer 
2013-11-06 16:30:14,077 INFO [com.taliantsoftware.flash.FlashRemotingServerProxy] |qatester|49|com.taliantsoftware.claims.ClaimService.retrieveClaimProfileItems 
2013-11-06 16:30:14,921 INFO [com.taliantsoftware.flash.FlashRemotingServerProxy] |qatester|3|com.taliantsoftware.claims.ClaimService.findClaims 

我使用以下OQL來獲得每種方法的平均和最大時間。 (utm,'。'))作爲方法,AVG(TO_INT(SUBSTR(utm,11,SUB(LAST_INDEX_OF(utm,'|'))作爲方法的一部分, ),11))))AS AVG_TIME,MAX(TO_INT(SUBSTR(utm,11,SUB(LAST_INDEX_OF(utm,'|'),11))))AS MAX_TIME,COUNT(*)FROM \ ced \ jboss \ node1 (utm,'| developer |')= 0或者INDEX_OF(utm,'| qatester |')= 0 AND(AVG(TO_INT '),11))))> 1000 OR MAX(TO_INT(SUBSTR(utm,11,SUB(LAST_INDEX_OF(utm,'|'),11))))> 1000)GROUP BY SUBSTR(utm,LAST_INDEX_OF(utm, ')'))ORDER BY AVG(TO_INT(SUBSTR(utm,11,SUB(LAST_INDEX_OF(utm,'|'),11))))DESC「

回答

0

您可以通過選擇一個生成Xml/Html輸出html文件並指定一個模板:

查詢

logparser -i:TSV -iSeparator:space -tpl:YOURTEMPLATE.tpl "SELECT /.../ COUNT(*) AS AGG INTO output.html FROM /.../" 

YOURTEMPLATE.tpl

<lpheader> 
<html> 
    <head></head> 
    <body> 
    <table> 
     <tr> 
     <th>method</th> 
     <th>avg time</th> 
     <th>max time</th> 
     <th>count</th> 
     </tr> 
</lpheader> 
<lpbody> 
     <tr> 
     <td>%METHOD%</td> 
     <td>%AVG_TIME%</td> 
     <td>%MAX_TIME%</td> 
     <td>%AGG%</td> 
     </tr> 
</lpbody> 
    </table> 
    </body> 
</html> 

adopted from Log Parser Rocks!

+0

這是給我的錯誤,如下面。錯誤:無效參數「tpl」 – user1614862

+0

LogParser -i:TSV -iSeparator:space -tpl:C:\ togo \ work \ log-analysis \ template.tpl「SELECT SUBSTR(user,LAST_INDEX_OF(user,'。'))AS方法,AVG(TO_INT(SUBSTR(user,11,SUB(LAST_INDEX_OF(user,'|'),11))))AS AVG_TIME,MAX(TO_INT(SUBSTR(user,11,SUB(LAST_INDEX_OF(user,'|') ),11))))AS MAX_TIME,COUNT(*)INTO C:\ togo \ work \ log-analysis \ server-log.html FROM C:\ jboss-5.1.0.GA-LAB \ server \ powersuite \ log \ user.log WHERE INDEX_OF(user,'| developer |')= 0或INDEX_OF(user,'| qatester |')= 0 AND(AVG(TO_INT(SUBSTR(user,11,SUB(LAST_INDEX_OF(user,'| '),11))))> 1000 --------- – user1614862

+0

嘗試將tpl:參數放在引號中,額外的冒號可能有問題,例如-tpl:「C:\ togo \ template.tpl」 – beavel