473,412 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Parsing the appended data of log file in real time

Hello all,

I have a log file that is appended to in real time by an application. I
would like to write a loop in vb.net that reads new entires and parses
them. I can get my application to open a file and read it all the way
through but I can not get it to continue looping after the file is
finished. I am trying to get the new additions to the log file to be
displayed in a textbox in real time. Any help is greatly appreciated.

Jun 12 '06 #1
3 2342
My guess is that you are opening the file and leaving it open while
you look for new data that is appended to the file by the other
software. This will not work because if you do not close the file and
re-open it, you will never know about any new data that is written to
it by the other program. You may also be blocking the other program
fom writing to the file.

The way that I would do things would be to check for the file to see
if it exists. If it does, then read in all the data from the file and
then append it all to the end of a second log file and then delete the
original log file. (I assume that the program that creates the log
file in the first place will automatically create the file if it does
not exist). Then all you need to do is to use a timer to check for the
original file every so often and if it exists, read it in, append it
to the second log file and delete the original exactly as described
above. If the file does not exist, then do nothing.
On 11 Jun 2006 20:25:08 -0700, "Paulers" <Su*******@gmail.com> wrote:
Hello all,

I have a log file that is appended to in real time by an application. I
would like to write a loop in vb.net that reads new entires and parses
them. I can get my application to open a file and read it all the way
through but I can not get it to continue looping after the file is
finished. I am trying to get the new additions to the log file to be
displayed in a textbox in real time. Any help is greatly appreciated.

Jun 12 '06 #2
Hi Thomas,

Actually another application is writing to the log file. I just need my
application to continue looping displaying anything that should enter
into the log file.

I found a visual basic script that is doing the same thing. I just need
to figure out how to do it in vb.net. CAn anyone help?
'scriptInAction is the control vairiable for the do util loop while
'scriptInAction is 1 the do loop continues
'either exit do or set scriptInAction to another number to end
'the script's loop
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''

dim scriptInAction
scriptInAction = 1
currentLine = "0"

Do While scriptInAction = 1
If logFile.AtEndOfStream <> True Then
currentLine = logFile.ReadLine
If InStr (currentLine, exitScript) Then
scriptInAction = 0
End If
If InStr (currentLine, masterName) And InStr (currentLine,
commandPhrase) Then
workingLine = StrReverse (currentLine)
workingLine2 = Split (workingLine, commandDelimiter, 1, 1)
workingLine = StrReverse (workingLine2)
WshShell.SendKeys ("/" & workingLine & "~")
End If
End If

WScript.echo currentLine
WScript.Sleep 50
currentLine = "holding"
Loop

Thomas Lutz wrote:
My guess is that you are opening the file and leaving it open while
you look for new data that is appended to the file by the other
software. This will not work because if you do not close the file and
re-open it, you will never know about any new data that is written to
it by the other program. You may also be blocking the other program
fom writing to the file.

The way that I would do things would be to check for the file to see
if it exists. If it does, then read in all the data from the file and
then append it all to the end of a second log file and then delete the
original log file. (I assume that the program that creates the log
file in the first place will automatically create the file if it does
not exist). Then all you need to do is to use a timer to check for the
original file every so often and if it exists, read it in, append it
to the second log file and delete the original exactly as described
above. If the file does not exist, then do nothing.
On 11 Jun 2006 20:25:08 -0700, "Paulers" <Su*******@gmail.com> wrote:
Hello all,

I have a log file that is appended to in real time by an application. I
would like to write a loop in vb.net that reads new entires and parses
them. I can get my application to open a file and read it all the way
through but I can not get it to continue looping after the file is
finished. I am trying to get the new additions to the log file to be
displayed in a textbox in real time. Any help is greatly appreciated.


Jun 13 '06 #3
Hello Paulers,

Check out the Stream.Peek function. When peek doesnt return any data then
sit in an idle loop till it does.. then continue blithly on your merry way.

-Boo
Hi Thomas,

Actually another application is writing to the log file. I just need
my application to continue looping displaying anything that should
enter into the log file.

I found a visual basic script that is doing the same thing. I just
need to figure out how to do it in vb.net. CAn anyone help?

'scriptInAction is the control vairiable for the do util loop while
'scriptInAction is 1 the do loop continues
'either exit do or set scriptInAction to another number to end
'the script's loop
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''
'''''''''''''
dim scriptInAction
scriptInAction = 1
currentLine = "0"
Do While scriptInAction = 1
If logFile.AtEndOfStream <> True Then
currentLine = logFile.ReadLine
If InStr (currentLine, exitScript) Then
scriptInAction = 0
End If
If InStr (currentLine, masterName) And InStr (currentLine,
commandPhrase) Then
workingLine = StrReverse (currentLine)
workingLine2 = Split (workingLine, commandDelimiter, 1, 1)
workingLine = StrReverse (workingLine2)
WshShell.SendKeys ("/" & workingLine & "~")
End If
End If
WScript.echo currentLine
WScript.Sleep 50
currentLine = "holding"
Loop
Thomas Lutz wrote:
My guess is that you are opening the file and leaving it open while
you look for new data that is appended to the file by the other
software. This will not work because if you do not close the file and
re-open it, you will never know about any new data that is written to
it by the other program. You may also be blocking the other program
fom writing to the file.

The way that I would do things would be to check for the file to see
if it exists. If it does, then read in all the data from the file and
then append it all to the end of a second log file and then delete
the original log file. (I assume that the program that creates the
log file in the first place will automatically create the file if it
does not exist). Then all you need to do is to use a timer to check
for the original file every so often and if it exists, read it in,
append it to the second log file and delete the original exactly as
described above. If the file does not exist, then do nothing.

On 11 Jun 2006 20:25:08 -0700, "Paulers" <Su*******@gmail.com> wrote:
Hello all,

I have a log file that is appended to in real time by an
application. I would like to write a loop in vb.net that reads new
entires and parses them. I can get my application to open a file and
read it all the way through but I can not get it to continue looping
after the file is finished. I am trying to get the new additions to
the log file to be displayed in a textbox in real time. Any help is
greatly appreciated.

Jun 13 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $...
0
by: Fabian Kr?ger | last post by:
Hello, I got a weird problem and need your help and ideas... I´ve written an php application which imports data in XML format and writes this data to a MySQL database to have a faster access....
9
by: Mantorok Redgormor | last post by:
If I am parsing a config file that uses '#' for comments and the config file itself is 1640 bytes, and the format is VARIABLE=VALUE, is it recommended to use a) fgetc (parse a character at a...
9
by: ankitdesai | last post by:
I would like to parse a couple of tables within an individual player's SHTML page. For example, I would like to get the "Actual Pitching Statistics" and the "Translated Pitching Statistics"...
1
by: Thomas Kowalski | last post by:
Hi, I have to parse a plain, ascii text file (on local HD). Since the file might be many millions lines long I want to improve the efficiency of my parsing process. The resulting data structure...
3
by: toton | last post by:
Hi, I have some ascii files, which are having some formatted text. I want to read some section only from the total file. For that what I am doing is indexing the sections (denoted by .START in...
31
by: broli | last post by:
I need to parse a file which has about 2000 lines and I'm getting told that reading the file in ascii would be a slower way to do it and so i need to resort to binary by reading it in large...
3
by: raghudr | last post by:
Hi all, I am parsing a .xml file.My main intention is to retrieve the name value of node "Signal":- "Name Value" which is "rag". i want to store only the <signal"name value" that is only...
6
by: i_robot73 | last post by:
I have a file, containing hex values for dates (MMDDYYYY)<status code><??such as: ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.