« Previous Next »

Thread: Need help parse IIS log

Last post 10-29-2009 6:10 AM by PatrickMc. 6 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (7 items)

Sort Posts:

  • 09-30-2009, 12:00 AM

    • togo413
    • Not Ranked
    • Joined on 09-30-2009, 3:56 AM
    • Posts 5

    Need help parse IIS log

    Hi everyone,

     

    I am new to log parse. Currently  download logparse2.2 . I need to implement a .net web app to parse the  iis site usage detail for iis log. I have try the sample provided in logparse2.2 . It seem doesn't work accordingly. Need help for sample code or any good guidance web site.

     

    Thanks

  • 09-30-2009, 3:07 AM In reply to

    Re: Need help parse IIS log

    You are referring to the COM interface of LP? I didn't work on that chapter, but the other two IIS chapters are by me that is of coz you are referring to the LP book.
    Cheers,
    Bernard Cheah
  • 09-30-2009, 3:20 AM In reply to

    • togo413
    • Not Ranked
    • Joined on 09-30-2009, 3:56 AM
    • Posts 5

    Re: Need help parse IIS log

    Hi,

     

    Thanks for reply me.

    I refer to the c# example in log parser help and add the LogParser.dll as reference to my web app.

    It running successfully now.

    But what the result show me is the record from windows event logs.

    I need to parse for IIS log.

    How can I modify that example code in order to parse from IIS log?

  • 09-30-2009, 4:34 AM In reply to

    Re: Need help parse IIS log

    Can you post the sample code? I think you can change the source rather than getting from Eventlog you can get it from IIS. From command line the source for event log is EVT, for IIS - you can specify IISW3C, NCSA/etc depending on what you got.

    Cheers,
    Bernard Cheah
  • 09-30-2009, 10:44 PM In reply to

    • togo413
    • Not Ranked
    • Joined on 09-30-2009, 3:56 AM
    • Posts 5

    Re: Need help parse IIS log

    I found the solution.

    Below is my codes. Thanks for help.

     

     

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using LogQuery = MSUtil.LogQueryClassClass;
    using iisLogInputFormat = MSUtil.COMIISW3CInputContextClassClass;
    using LogRecordSet = MSUtil.ILogRecordset;

    public partial class Default2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
       
                LogQuery oLogQuery = new LogQuery();
     
                iisLogInputFormat oiisInputFormat = new iisLogInputFormat();
     
                string query = @"SELECT TOP 50  cs-username,cs-uri-stem , date FROM c:\LogFiles\W3SVC1009132659\ex*.log";

        
                LogRecordSet oRecordSet = oLogQuery.Execute(query, oiisInputFormat);

                int conter;
                conter = 0;
                // Browse the recordset
                for (; !oRecordSet.atEnd(); oRecordSet.moveNext())
                {
                    Response.Write(conter);
                    Response.Write("<br/>");
                    Response.Write(oRecordSet.getRecord().toNativeString(","));
                    Response.Write("<br/><br/>");
                    conter++;
                }

                // Close the recordset
                oRecordSet.close();
            }
            catch (System.Runtime.InteropServices.COMException exc)
            {
                Response.Write("Unexpected error: " + exc.Message);
            }

        }
    }

  • 10-01-2009, 3:16 AM In reply to

    Re: Need help parse IIS log

    Ya. you need to tell it where format first - iisLogInputFormat();
    Cheers,
    Bernard Cheah
  • 10-29-2009, 6:10 AM In reply to

    Re: Need help parse IIS log

     

    If you ever need to write your own custom log parser (like I did because the management wanted custom reports), here is a good sample custom log parsing script - http://www.biterscripting.com/helppages/SS_WebLogParser.html . It is a good starting point.

     

    Patrick

     

Page 1 of 1 (7 items)
Microsoft Communities