// static void Example200(TextReader textReader) { var reader = new W3CReader(textReader); foreach (var webevent in reader.Read().Where(w => w.Status >= 200 && w.Status < 300) .OrderBy(w => w.Status) .ThenBy(w => w.Date) .ThenBy(w => w.UriStem) .ThenBy(w => w.UriQuery)) { Console.WriteLine("{0} {1}", webevent.Status.ToString().Red().Bold(), webevent.UriStem); } }
// Return a listing of Web pages, and referring pages, that returned a 500 status code static void Example500(TextReader textReader) { var reader = new W3CReader(textReader); foreach (var webevent in reader.Read().Where(w => w.Status >= 500 && w.Status <= 600) .OrderBy(w => w.Status) .ThenBy(w => w.Date) .ThenBy(w => w.UriStem) .ThenBy(w => w.UriQuery)) { Console.WriteLine("{0}\t{1}\t{2}{3}", webevent.Status.ToString().Red().Bold(), webevent.ToLocalTime(), webevent.UriStem.Blue(), webevent.UriQuery.Yellow()); } }
static void Main(string[] args) { var reader = new W3CReader(File.OpenText(args.Length > 0 ? args[0] : "Data/foobar.log")); using (new ConsoleAutoStopWatch()) { foreach (var @event in reader.Read()) { Console.WriteLine("{0} ({1}):{2}/{3} {4} (bytes sent)", @event.Status.ToString().Red().Bold(), @event.ToLocalTime(), @event.UriStem.Green(), @event.UriQuery, @event.BytesSent); } } }