appending and reading text file

Posted by Rod on Stack Overflow See other posts from Stack Overflow or by Rod
Published on 2012-09-06T03:30:07Z Indexed on 2012/09/06 3:38 UTC
Read the original article Hit count: 94

Filed under:

Environment: Any .Net Framework welcomed. I have a log file that gets written to 24/7.

I am trying to create an application that will read the log file and process the data.

What's the best way to read the log file efficiently? I imagine monitoring the file with something like FileSystemWatcher. But how do I make sure I don't read the same data once it's been processed by my application? Or say the application aborts for some unknown reason, how would it pick up where it left off last?

There's usually a header and footer around the payload that's in the log file. Maybe an id field in the content as well. Not sure yet though about the id field being there.

I also imagined maybe saving the lines read count somewhere to maybe use that as bookmark.

© Stack Overflow or respective owner

Related posts about c#