4

I have to monitor a large log file during the day with C#. The size goes up to 200-300 MB for a day.
What is the most efficient way to analyze it?
The file is locked by the producing program. Preferably I would either have a read which realises that lines have been added or would read backwards.

weismat
  • 7,195
  • 3
  • 43
  • 58

3 Answers3

3

A combination of MemoryMappedFile and FileSystemWatcher should do the trick.

Oliver
  • 43,366
  • 8
  • 94
  • 151
1

You will never achieve good results with C#.

I created application in C++ and I used MFC String to search 1GB file.
It takes about 15-20 seconds. After that I used char type and it takes about 3 sec!!!!

C# has lot of overhead and if you need really fast solution, use C++ and TCHAR, char, data type.

bipen
  • 36,319
  • 9
  • 49
  • 62
opis
  • 37
  • 1
0

Change log rotation to a smaller value and then process the rotated logs - or - Process the whole log file the first time and remember the fileoffset / line for the next checking interval.

DCA
  • 1