UPDATE
thanks for the comments. i bug fixed and added the suggestions to the code.
Weeks ago i promised to post my ASP.NET frontend for the LogParser tool, but I haven’t had the time to hunt down some bugs and finalize it. (i also found another project called ‘ServerStat’ which you can download on www.logparser.com).
However – i thought i post the most important part of the tool – which is a little method that queries LogParser through COM Interop and converts the results to a DataSet.
private DataSet parseLog(string query)
{
LogQueryClassClass logParser = new LogQueryClassClass();
COMIISW3CInputContextClassClass iisLog = new COMIISW3CInputContextClassClass();
ILogRecordset rsLP = null;
ILogRecord rowLP = null;
rsLP = logParser.Execute(query, iisLog);
DataTable tab = new DataTable(“Results”);
// copy schema
for (int i = 0; i < rsLP.getColumnCount(); i++)
{
DataColumn col = new DataColumn();
col.ColumnName = rsLP.getColumnName(i);
switch (rsLP.getColumnType(i))
{
case 1:
col.DataType = Type.GetType(“System.Int32”);
break;
case 2:
col.DataType = Type.GetType(“System.Double”);
break;
case 4:
col.DataType = Type.GetType(“System.DateTime”);
break;
default:
col.DataType = Type.GetType(“System.String”);
break;
}
tab.Columns.Add(col);
}
// copy data
while (!rsLP.atEnd())
{
rowLP = rsLP.getRecord();
DataRow row = tab.NewRow();
for (int i = 0; i < rsLP.getColumnCount(); i++)
row[i] = HttpUtility.HtmlEncode(Convert.ToString(rowLP.getValue(i)));
tab.Rows.Add(row);
rsLP.moveNext();
}
DataSet ds = new DataSet();
ds.Tables.Add(tab);
return ds;
}
