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.
Asked
Active
Viewed 2,987 times
4

weismat
- 7,195
- 3
- 43
- 58
3 Answers
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.
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