예제 #1
0
 public void Init()
 {
     LogLineString = "83.86.171.177 - - [15/May/2013:04:03:01 +0200] \"GET /weer/turfWeer HTTP/1.1\" 200 499 \"-\" \"Java/1.7.0_05\"";
     LogLine = new ApacheLogLine()
     {
         IP = "83.86.171.177",
         Date = DateTime.ParseExact("[15/May/2013:04:03:01]", "[dd/MMM/yyyy:HH:mm:ss]", CultureInfo.InvariantCulture),
         Command = "GET /weer/turfWeer HTTP/1.1",
         Status = HttpStatusCode.OK,
         Time = 499,
         UserAgent = "Java/1.7.0_05"
     };
 }
 /// <summary>
 /// Parses a single line into a apacha log line class
 /// </summary>
 /// <param name="line"></param>
 /// <returns></returns>
 public ApacheLogLine ParseLine(string line)
 {
     var result = new ApacheLogLine();
     var lines = line.Split(' ');
     result.OriginalLine = line;
     result.IP = IPAddress.Parse(lines[0]);
     result.Date = DateTime.ParseExact(lines[3]+lines[4], DateTimeFormat, CultureInfo.InvariantCulture);
     result.Command = lines[5];
     result.Url = lines[6];
     result.Status = (HttpStatusCode)Enum.Parse(typeof(HttpStatusCode), lines[8]);
     result.Time = int.Parse(lines[9]);
     result.UserAgent = lines[11];
     return result;
 }
예제 #3
0
 public static void LogApacheLogLine(ApacheLogLine line)
 {
     GetConsoleHub().SendMessage("LogLines", line.ToString());
 }