C#: Parse IIS log-files efficient, create statistics
what is the best way to parse an IIS 7 log file? Are there f开发者_JAVA技巧ree c# classes I can use or is there a little example project?
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:
You're looking for LogParser.
For good open source alternatives, check out awstats. Analog is another good option.
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);
}
精彩评论