I have a log file in the following format, since you can see each run in the log over time and end with a pipe metric.
Put each log starting with dateTime and ending with a tunnel in the list
How can I parse this text file and put the logs in collections? It seems that I have a problem in determining how I can find the beginning and end of a journal and read it every journal
The following is a brief example to give an idea of what I'm trying to do. Any pointers help etc ... really appreciated
Log Example
08:52:03.260|Error| Stack Trace and other info removed here|
lots of info about the stack trace
lots of info about the stack trace
lots of info about the stack trace
lots of info about the stack trace
lots of info about the stack trace|
09:52:03.260|Error| Stack Trace and other info removed here|
lots of info about the stack trace
lots of info about the stack trace
lots of info about the stack trace
lots of info about the stack trace
lots of info about the stack trace|
09:52:03.260|Error|Stack Trace and other info removed here|
lots of info about the stack trace
lots of info about the stack trace
lots of info about the stack trace
lots of info about the stack trace
lots of info about the stack trace|
File 2 Scenario My Order
Quantity Description Price
1 shoes £1.00
Total £1.00
No: 34343345
My Order
Quantity Description Price
1 TShirt £1.00
Total £1.00
No: 32234234
Program:
class Program
{
static void Main(string[] args)
{
string path = @"MyTestLog.log";
string aa = string.Empty;
List<LogMessage>logMessages=new List<LogMessage>();
using (StreamReader reader = new StreamReader(path))
{
logMessages.Add(new LogMessage
{
Time = ??,
ErrorLevel = ,
Details = ??
});
}
}
}
public class LogMessage
{
public DateTime Time { get; set; }
public string ErrorLevel { get; set; }
public string Details { get; set; }
}
source
share