0

Is it possible to generate HTML output from the log parser? I'd like to directly parse log files which are in log4j format. It is expecting column header to pickup the contents of each line.

Currently I am manually adding the few column header to get the line contents in the select clause. Is it possible to read the content without adding the new line.

I have the plenty of lines of below kind which I want to process for some report.

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

I use the following OQL to get average and max times of each method.

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"
TylerH
  • 20,799
  • 66
  • 75
  • 101
user1614862
  • 3,701
  • 7
  • 29
  • 46

1 Answers1

0

You can generate Xml/Html output by selecting into a html file and specifying a template:

Query

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!

Filburt
  • 17,626
  • 12
  • 64
  • 115
  • It is giving me an error like below. Error: invalid parameter "tpl" – user1614862 Nov 21 '13 at 00:05
  • LogParser -i:TSV -iSeparator:space -tpl:C:\togo\work\log-analysis\template.tpl "SELECT SUBSTR(user, LAST_INDEX_OF(user, '.')) AS METHOD, 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\server.log WHERE INDEX_OF(user, '|developer|')=0 OR INDEX_OF(user, '|qatester|')=0 AND (AVG(TO_INT(SUBSTR(user, 11,SUB(LAST_INDEX_OF(user, '|'), 11)))) > 1000 --------- – user1614862 Nov 21 '13 at 00:07
  • Try putting the tpl: parameter in quotes. The extra colon might be problematic. E.g. -tpl:"C:\togo\template.tpl" – beavel Nov 21 '13 at 01:22
  • 1
    Also add "-o:TPL" to tell LogParser explicitly to use the "TPL" (i.e. "template") output format. – Gabriele Giuseppini Nov 21 '13 at 17:11
  • @Gabriele Giuseppini, thank you!! It has worked after adding -O flag. Now my other question is how to read the log file without adding column header to it? Because my log file is generated by log4j where I cannot have the header automatically generated by log4j. I need to add it every time I want to parse it using log parser. So any work around? – user1614862 Nov 25 '13 at 19:30
  • @user1614862 Could you put your column header problem into a new question? The query in your comment is different from the one in your OP and your sample log doesn't show any header. From what we can see here you simply create your column names by `... AS ` in your query. – Filburt Nov 25 '13 at 20:03
  • 1
    You can impose headers using the "-iHeaderFile" option follwoed by the path to a file that contains a single header line. Or use "AS " as Filburt suggests. – Gabriele Giuseppini Nov 26 '13 at 14:54