Scanning/rebuilding logs

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello all,

I need to scan and rebuild logs dependent upon a certain time span, i.e. anything over 4 days older
than today. The beginning of each entry is formatted yyyy/mm/dd hr:min:sec. Now, I know I can have
a loop of reading in and creating a TimeSpan object from each entry, call it 'T1', and subtract today's date, call
it 'T0', from 'T1' and if the difference is equal to or greater than 4 days remove the entry; continue
looping until an entry is less than or equal to 4 days. But, for some reason that seems awfully
inefficient?

Seems to me I should be able to use RegEx somehow, but I'm just not sure how. Does anybody have
any experience with a 'efficient log scanner' or any ideas along these lines?

TIA,

Ray K.
 
Ray K.

You could use a regular expression. However, I am not sure which one
you would use.

Personally, if I had the choice, I would import the log into a SQL
server table (using Data Transformation Services) and then just query the
table created to determine how to import the log. Basically, you can set up
a pre-defined package to import your log file (which I am sure is in some
sort of delimited format) into SQL server (or some other data format). Once
it is there, querying the data you want should be a breeze.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

raykos said:
Hello all,

I need to scan and rebuild logs dependent upon a certain time span,
i.e. anything over 4 days older
than today. The beginning of each entry is formatted yyyy/mm/dd
hr:min:sec. Now, I know I can have
a loop of reading in and creating a TimeSpan object from each entry, call
it 'T1', and subtract today's date, call
it 'T0', from 'T1' and if the difference is equal to or greater than 4
days remove the entry; continue
 
Back
Top