Looking at this log file, I have more than one new lines ( Even here That I have till now and model I will use and break the file that matches the date pattern (E.g., \ n ) How can I read a line with a
StreamReader ? The
ReadLine method actually returns each row, but a message may be more than one line.
using
(var sr = new StreamReader (filePath)) (Var store = new documentstore {ConnectionStringName = "RavenDB"}. Initialize ()) {IndexCreation. CreateIndexes (typef (Logs_Search). Assembly, store); (Using var bulkInsert = store.BulkInsert ()) {const char column delimiter = ';'; Const String Coat = @ "~"; String line; While trying (item = sr.ReadLine ())! = Null {batch ++; list & lt; string & gt; column = null; {Columns = line.plit (columnDelimeter) Select (item = & Gt; Item. Replay (quote, string.opt)). Olist (); if (column.Count! = 5) {batch--; log error (string .joined (",", column.toArray) ); Continue;} BulkInsert.Store (LogParser.Log.FromStringList (column)); / * Give some feedback / (/ batch% 100000 == 0) {log debug ("batch: {0}", batch );} / * Use abbreviations * / if (throttled and batch% ThrottleBatchSize == 0) { Thread.Sleep (ThrottleThreadWait);}} Catch (format expansion) {if (column! = Null) log error (string .joined (",", column.to array ());} hold (exception exception) {} Log error (exception);}}}}
public class log {public string component {get; set;} public string date time {Get; set;} Public string logger {get; set;} public string level {get; set;} public string threadId {get; set;} public string message {get; Set; } Public String Terms {get; Set; } String list from public static log (list & lt; string & gt; line) {log log = new log (); /*log.Component = line [0] == string Empty? Zero: Line [0]; * / Log.DateTime = Row [0] == string. Empty? Zero: Line [0]. Olavar (); Logs. Logger = row [1] == string Empty? Empty: line [1]. Lower (); Logs. Level = line [2] == string Empty? Zero: Line [2]. Tolavar (); Log.ThreadId = line [3] == string. Empty? Empty: line [3]. Tolavar (); Logs. Message = line [4] == string Empty? Empty: line [4]. Tolavar (); Return log; }}
2013-06-19 ) at the beginning of each error.
No comments:
Post a Comment