2

what is the best way to parse an IIS 7 log file? Are there free c# classes I can use or is there a little example project?

4 Answers 4

4

I agree with SLaks, LogParser is your top bet. Most, if not all of its functionality is exposed via a COM API which you could import into your project via COM interop:

alt text

Sign up to request clarification or add additional context in comments.

Comments

3

You're looking for LogParser.

Comments

3

For good open source alternatives, check out awstats. Analog is another good option.

Comments

1

Are there free c# classes I can use or is there a little example project?

I wrote a little parser class in C# (.NET Core). See source here https://github.com/alexnolasco/32120528/

Example,

// List requests by hour
var q = new W3CReader(textReader).Read()
             .GroupBy(r => r.UtcTime().RoundUp(TimeSpan.FromHours(1)))
             .Select(g => new
             {
                    Hour = g.Key,
                    Count = g.Count()
             });
foreach (var r in q)
{
    Console.WriteLine("{0}\t{1}", r.Hour, r.Count);
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.