是否可以从microsoft日志解析器输出html?

时间:2013-11-20 23:16:05

标签: logging logparser html-formatting

我想从日志解析器生成html输出,是否可能?如何直接解析log4j格式的日志文件。期望列标题拾取每行的内容。目前我手动添加几个列标题以获取select子句中的行内容。是否可以在不添加新行的情况下阅读内容。

我有很多以下类型的行,我想处理一些报告。

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来获取每种方法的平均值和最大值。

LogParser -i:TSV -iSeparator:space“SELECT SUBSTR(utm,LAST_INDEX_OF(utm,'。'))AS METHOD,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 \ temp.log WHERE INDEX_OF(utm,'| developer |')= 0 OR INDEX_OF(utm,'| qatester |')= 0 AND(AVG(TO_INT(SUBSTR(utm,11,SUB)(LAST_INDEX_OF(utm,'|') ),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“

1 个答案:

答案 0 :(得分:0)

您可以通过选择html文件并指定模板来生成Xml / 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!