I’m not for sure if this is possible with Log Parser, but I’m trying to create an HTML report to include multiple IIS statistics. I don’t have any issues creating a report with just a single Log Parser query, but I want to be able to include multiple queries within a PowerShell script to create just one report.
I’ve created the .tpl template file to except values from multiple queries into and HTML table, but each time Log Parser runs you only have the options with the filemode parameter to append or overwrite the file. Appending the HTML output file just creates multiple tables and doesn’t just insert the data into the single table from multiple queries.
The only option I can think of is to somehow create multiple queries within a single large query or join them together so Log Parser only needs to be run once and won’t overwrite/append the HTML output file each time it runs. But I don't think Log Parser will work with nested Select statements.
Any ideas on how to get this work would be greatly appreciated.
Edit: Code Examples below
This is snippet of the .tpl file containing a table with four columns that I would like to populate each column with data from four separate log parser queries (unique users by app)
<LPBODY>
<TH COLSPAN=4 BGCOLOR="BLACK"><FONT Size =4 COLOR=WHITE>Number of Unique Visitors </FONT>
<tr><th>App1</th><th>App2</th><th>App3</th><th>app4</th>
<TD>%App1%</TD><TD>%App2%</TD><TD>%App3%</TD><TD>%App4%</TD>
</LPBODY>
Snippet of the PowerShell script containing a few log parser queries that will create the HTML file using the .tpl template file.
#Find unique users for App1 and insert into the HTML File
$UniqueUserApp1 = "SELECT COUNT(DISTINCT cs-username) AS App1 `
INTO Report.html FROM C:\IISLogs `
WHERE cs-uri-stem LIKE '%app1%' `
AND cs-username is not null
logparser i:W3C $UniqueUserApp1 -tpl:HTMLTemplate.tpl -fileMode:0
#Find unique users for App2 and insert into the HTML File
$UniqueUserApp1 = "SELECT COUNT(DISTINCT cs-username) AS App2 `
INTO Report.html FROM C:\IISLogs `
WHERE cs-uri-stem LIKE '%app2%' `
AND cs-username is not null
logparser i:W3C $UniqueUserApp2 -tpl:HTMLTemplate.tpl -fileMode:0
The problem that I am running into is when each log parser query runs, it just creates a separate table with just one value populated in each table in the HTML report instead of populating the value of %app1% and %app2% within a single table. This appears to be setup by design with Log Parser, so I am looking for a possible work around to create a structured HTML page with tables that I can populate from Log Parser Queries.