[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 201
  • Last Modified:

Reading from an open file

I'd like to read from a text file and parse through it in real time. i.e. I have a log file that remains open and is being written to. I want a log file watcher that reads the new line of data after it's been written and do something with it.  How would I start this?
0
jayrod
Asked:
jayrod
1 Solution
 
RomanPetrenkoCommented:
Hi jayrod,

Create logger component with event OnWrite that fired when you write any string into log file. As parameter of event you can transfer string written into logger. In log watcher register some event handler for event OnWrite. In this handler you can do everything you want with new string. That way you do not need directly the file but you will know about newly added entries even before it physically stored on disk (I'm sure you remember about filestream cache that doesn't flush immediately after write).

Cheers!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now