Web :: Performance issues :: Differential Reading from a text file |
|||
| By: Najja |
Date: 20/06/2003 00:00:00 |
Points: 25 | Status: Answered Quality : Excellent |
|
Hello All, My requirement may sound silly, but I badly need a solution. I'm using VB.Net I want to read from a log file, which is being updated frequently from another program, and process the information. This can be done. But I want to read the same log file again and again. That time there's no use of reading the old data which has already been processes. I cant purge the log file as I don have the ownership of that. So please tell me how can I read the differential data from the log file so that the growth of the log file wont effect the performance of my program. Thanks in advance |
|||
| By: VGR | Date: 20/06/2003 05:45:00 | Type : Answer |
|
| classical problem. Either call some OS program/command like "tail" with parameters, or memorize after each processing the position/datetime of the last entry read, and try to read only the following lines the next time [not easy] personally, I solve this problem by log-rotating the logs so that they stay small enough to permit fast read into memory |
|||
| By: dbrunton | Date: 20/06/2003 19:42:00 | Type : Comment |
|
| If the log file is just being added too then count the number of lines when you process the file and save this number in a text file. Next time get the number out of this text file and just read without processing this number of lines. Now process the rest of file counting the extra lines. Total new number of lines and count you got out of text file and drop this total back into text file for next time. |
|||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








