Curated Examples
Parse IIS logs in .NET
Use ParserEngine directly from .NET code.
This pattern is useful when IIS log parsing belongs inside an application, test, or service.
It is adapted from IISParser.Tests/ParserEngineTests.cs.
Example
using IISParser;
var logPath = Path.Combine(AppContext.BaseDirectory, "samples", "u_ex230101.log");
using var parser = new ParserEngine(logPath)
{
MaxFileRecord2Read = 50000
};
foreach (var record in parser.ParseLog())
{
Console.WriteLine($"{record.Timestamp:o} {record.UriPath} {record.StatusCode}");
}
What this demonstrates
- using the library without PowerShell
- setting a maximum record count for predictable processing
- consuming typed IIS log records