By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,894 Members | 1,937 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,894 IT Pros & Developers. It's quick & easy.

How to dynamically display entries made into a growing log file

P: n/a
Happy Friday everyone!!!

I am working on a windows service and a C# application and needed some
help with certain functionality. Please read through my issue below.
Thanks!

I have a windows service which writes into a log file periodically
(text file). I want to create a windows form application, which, upon
invocation should continuously display the contents of the log file.
Even the newly made entries into the log file while the windows form
application has started running should be displayed dynamically at run
time.

Is that possible? and how should I go about it.

If such continuous monitoring of a log file cannot be implemented as a
windows form app, then how else could that be implemented?

The main idea is to continuously display to the user the entries that
are being made to the log file by the windows service.

I would be more than happy to provide any further information.

Thanks a lot for any help!!!
BS

Sep 29 '06 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Without knwoing your reason for wanting to do this i will do my best to
help.

I wouldnt do this in a logfile text document. Your IO isslower and more
intensive.

i would make a database back end, and have a table int hat called LogData or
whatever you want and as you need to write logs, insert a row.

You'd gain the benefits of easy timestamping your entries, fast searching
through your entries via indexes, quick IO, sorting...the list is endless.

Then for reading back just read the data in the table back out, inserts can
happen while reading out data and all would work well. Is this method not an
option for you?

"Suman" <ge********@gmail.comwrote in message
news:11*********************@m73g2000cwd.googlegro ups.com...
Happy Friday everyone!!!

I am working on a windows service and a C# application and needed some
help with certain functionality. Please read through my issue below.
Thanks!

I have a windows service which writes into a log file periodically
(text file). I want to create a windows form application, which, upon
invocation should continuously display the contents of the log file.
Even the newly made entries into the log file while the windows form
application has started running should be displayed dynamically at run
time.

Is that possible? and how should I go about it.

If such continuous monitoring of a log file cannot be implemented as a
windows form app, then how else could that be implemented?

The main idea is to continuously display to the user the entries that
are being made to the log file by the windows service.

I would be more than happy to provide any further information.

Thanks a lot for any help!!!
BS

Sep 29 '06 #2

P: n/a

Daniel wrote:
Without knwoing your reason for wanting to do this i will do my best to
help.

I wouldnt do this in a logfile text document. Your IO isslower and more
intensive.

i would make a database back end, and have a table int hat called LogData or
whatever you want and as you need to write logs, insert a row.

You'd gain the benefits of easy timestamping your entries, fast searching
through your entries via indexes, quick IO, sorting...the list is endless.

Then for reading back just read the data in the table back out, inserts can
happen while reading out data and all would work well. Is this method not an
option for you?

"Suman" <ge********@gmail.comwrote in message
news:11*********************@m73g2000cwd.googlegro ups.com...
Happy Friday everyone!!!

I am working on a windows service and a C# application and needed some
help with certain functionality. Please read through my issue below.
Thanks!

I have a windows service which writes into a log file periodically
(text file). I want to create a windows form application, which, upon
invocation should continuously display the contents of the log file.
Even the newly made entries into the log file while the windows form
application has started running should be displayed dynamically at run
time.

Is that possible? and how should I go about it.

If such continuous monitoring of a log file cannot be implemented as a
windows form app, then how else could that be implemented?

The main idea is to continuously display to the user the entries that
are being made to the log file by the windows service.

I would be more than happy to provide any further information.

Thanks a lot for any help!!!
BS
Thank you very much for the quick reply.

1) We have not just one but some number of windows services which
create log files. The log file process is not expected to be changed in
these just for this additional functionality. As of now, I have to only
consider that they will generate text based log files and not DB.

2) The reason we want to do this is because, when there is some error
at the custormer site, we now ask them to physically open up the log
file and tell us what entries they find in there.(May sound like we
live in the stone age but thats what it is :)..). We want to provide an
interface for the users to look at as the log file is being populated.

So, generally my questinn would be, is it possible to read a
dynamically populated file during runtime and display the entries as
the output? also including the new entries being made to our output as
and when they are made?

Thanks again for your time!
BS

Sep 29 '06 #3

P: n/a
You can implement a listbox control to do it and always make sure that the
latest entry has focus.

Suman wrote:
Happy Friday everyone!!!

I am working on a windows service and a C# application and needed some
help with certain functionality. Please read through my issue below.
Thanks!

I have a windows service which writes into a log file periodically
(text file). I want to create a windows form application, which, upon
invocation should continuously display the contents of the log file.
Even the newly made entries into the log file while the windows form
application has started running should be displayed dynamically at run
time.

Is that possible? and how should I go about it.

If such continuous monitoring of a log file cannot be implemented as a
windows form app, then how else could that be implemented?

The main idea is to continuously display to the user the entries that
are being made to the log file by the windows service.

I would be more than happy to provide any further information.

Thanks a lot for any help!!!
BS
Sep 29 '06 #4

P: n/a
Check out this article: http://www.codeproject.com/useritems/mytail.asp

-Matt

"Suman" wrote:
Happy Friday everyone!!!

I am working on a windows service and a C# application and needed some
help with certain functionality. Please read through my issue below.
Thanks!

I have a windows service which writes into a log file periodically
(text file). I want to create a windows form application, which, upon
invocation should continuously display the contents of the log file.
Even the newly made entries into the log file while the windows form
application has started running should be displayed dynamically at run
time.

Is that possible? and how should I go about it.

If such continuous monitoring of a log file cannot be implemented as a
windows form app, then how else could that be implemented?

The main idea is to continuously display to the user the entries that
are being made to the log file by the windows service.

I would be more than happy to provide any further information.

Thanks a lot for any help!!!
BS

Sep 29 '06 #5

P: n/a

Ian Semmel wrote:
You can implement a listbox control to do it and always make sure that the
latest entry has focus.

Suman wrote:
Happy Friday everyone!!!

I am working on a windows service and a C# application and needed some
help with certain functionality. Please read through my issue below.
Thanks!

I have a windows service which writes into a log file periodically
(text file). I want to create a windows form application, which, upon
invocation should continuously display the contents of the log file.
Even the newly made entries into the log file while the windows form
application has started running should be displayed dynamically at run
time.

Is that possible? and how should I go about it.

If such continuous monitoring of a log file cannot be implemented as a
windows form app, then how else could that be implemented?

The main idea is to continuously display to the user the entries that
are being made to the log file by the windows service.

I would be more than happy to provide any further information.

Thanks a lot for any help!!!
BS
Thanks for the reply Ian.

Will the ListBox update itself during runtime when there has been a new
entry into the log file?

Sep 29 '06 #6

P: n/a
You could also setup a file system watcher to monitor the file that is
being viewed. When a change happens to the file an event in your
application will fire. You can then compare what you have to the file
on the disk and append the newer data to the version you are displaying
on the screen.

To watch the file just do something like this:
http://abstractvb.com/code.asp?A=1000
Kelly Elias
Webmaster
http://devdistrict.com
Suman wrote:
Ian Semmel wrote:
You can implement a listbox control to do it and always make sure that the
latest entry has focus.

Suman wrote:
Happy Friday everyone!!!
>
I am working on a windows service and a C# application and needed some
help with certain functionality. Please read through my issue below.
Thanks!
>
I have a windows service which writes into a log file periodically
(text file). I want to create a windows form application, which, upon
invocation should continuously display the contents of the log file.
Even the newly made entries into the log file while the windows form
application has started running should be displayed dynamically at run
time.
>
Is that possible? and how should I go about it.
>
If such continuous monitoring of a log file cannot be implemented as a
windows form app, then how else could that be implemented?
>
The main idea is to continuously display to the user the entries that
are being made to the log file by the windows service.
>
I would be more than happy to provide any further information.
>
Thanks a lot for any help!!!
BS
>

Thanks for the reply Ian.

Will the ListBox update itself during runtime when there has been a new
entry into the log file?
Sep 29 '06 #7

P: n/a
Well, seems a very very inefficient way to do it to me and very unscalable
but ok.

The other posts seem to be right for your needs, i dont fully understand the
objective tho so i cant offer much further help. Hope you get it solved.

"Suman" <ge********@gmail.comwrote in message
news:11*********************@k70g2000cwa.googlegro ups.com...
>
Daniel wrote:
>Without knwoing your reason for wanting to do this i will do my best to
help.

I wouldnt do this in a logfile text document. Your IO isslower and more
intensive.

i would make a database back end, and have a table int hat called LogData
or
whatever you want and as you need to write logs, insert a row.

You'd gain the benefits of easy timestamping your entries, fast searching
through your entries via indexes, quick IO, sorting...the list is
endless.

Then for reading back just read the data in the table back out, inserts
can
happen while reading out data and all would work well. Is this method not
an
option for you?

"Suman" <ge********@gmail.comwrote in message
news:11*********************@m73g2000cwd.googlegr oups.com...
Happy Friday everyone!!!

I am working on a windows service and a C# application and needed some
help with certain functionality. Please read through my issue below.
Thanks!

I have a windows service which writes into a log file periodically
(text file). I want to create a windows form application, which, upon
invocation should continuously display the contents of the log file.
Even the newly made entries into the log file while the windows form
application has started running should be displayed dynamically at run
time.

Is that possible? and how should I go about it.

If such continuous monitoring of a log file cannot be implemented as a
windows form app, then how else could that be implemented?

The main idea is to continuously display to the user the entries that
are being made to the log file by the windows service.

I would be more than happy to provide any further information.

Thanks a lot for any help!!!
BS

Thank you very much for the quick reply.

1) We have not just one but some number of windows services which
create log files. The log file process is not expected to be changed in
these just for this additional functionality. As of now, I have to only
consider that they will generate text based log files and not DB.

2) The reason we want to do this is because, when there is some error
at the custormer site, we now ask them to physically open up the log
file and tell us what entries they find in there.(May sound like we
live in the stone age but thats what it is :)..). We want to provide an
interface for the users to look at as the log file is being populated.

So, generally my questinn would be, is it possible to read a
dynamically populated file during runtime and display the entries as
the output? also including the new entries being made to our output as
and when they are made?

Thanks again for your time!
BS

Sep 30 '06 #8

P: n/a


Suman wrote:
Ian Semmel wrote:
>>You can implement a listbox control to do it and always make sure that the
latest entry has focus.

Suman wrote:
>>>Happy Friday everyone!!!

I am working on a windows service and a C# application and needed some
help with certain functionality. Please read through my issue below.
Thanks!

I have a windows service which writes into a log file periodically
(text file). I want to create a windows form application, which, upon
invocation should continuously display the contents of the log file.
Even the newly made entries into the log file while the windows form
application has started running should be displayed dynamically at run
time.

Is that possible? and how should I go about it.

If such continuous monitoring of a log file cannot be implemented as a
windows form app, then how else could that be implemented?

The main idea is to continuously display to the user the entries that
are being made to the log file by the windows service.

I would be more than happy to provide any further information.

Thanks a lot for any help!!!
BS


Thanks for the reply Ian.

Will the ListBox update itself during runtime when there has been a new
entry into the log file?
The simplest basic thing is something like this

public override void LogLine ( string s )
{
seqNo += 1;
string str = seqNo.ToString ( "##### " );
lb.Items.Add ( str + s );
lb.SetSelected ( lb.Items.Count - 1, true );
}

You could incorporate this into where you log to the file.
However, if you want to get more sophisticated, you will have to do more work
(like not updating the listbox while the user is browsing the log and then
"catching up" when they have finished and paging data when it gets too large).
If you understand MFC, Joseph Newcomer has a good logging listbox at
www.flounder.com where you could get some ideas.
Sep 30 '06 #9

P: n/a
Thank you very much for all your help. I have used a combination of
Timer and the FileSystemWatcher class to implement the solution.

I didnt know how to put the FileSystemWatcher in an infinite loop and
yet have the disply work as needed. Hence I used a timer for calling
the FileSystemWatcher part of the code periodically.

Thank you and have a great day!
Suman
Ian Semmel wrote:
Suman wrote:
Ian Semmel wrote:
>You can implement a listbox control to do it and always make sure that the
latest entry has focus.

Suman wrote:

Happy Friday everyone!!!

I am working on a windows service and a C# application and needed some
help with certain functionality. Please read through my issue below.
Thanks!

I have a windows service which writes into a log file periodically
(text file). I want to create a windows form application, which, upon
invocation should continuously display the contents of the log file.
Even the newly made entries into the log file while the windows form
application has started running should be displayed dynamically at run
time.

Is that possible? and how should I go about it.

If such continuous monitoring of a log file cannot be implemented as a
windows form app, then how else could that be implemented?

The main idea is to continuously display to the user the entries that
are being made to the log file by the windows service.

I would be more than happy to provide any further information.

Thanks a lot for any help!!!
BS

Thanks for the reply Ian.

Will the ListBox update itself during runtime when there has been a new
entry into the log file?

The simplest basic thing is something like this

public override void LogLine ( string s )
{
seqNo += 1;
string str = seqNo.ToString ( "##### " );
lb.Items.Add ( str + s );
lb.SetSelected ( lb.Items.Count - 1, true );
}

You could incorporate this into where you log to the file.
However, if you want to get more sophisticated, you will have to do more work
(like not updating the listbox while the user is browsing the log and then
"catching up" when they have finished and paging data when it gets too large).
If you understand MFC, Joseph Newcomer has a good logging listbox at
www.flounder.com where you could get some ideas.
Oct 4 '06 #10

This discussion thread is closed

Replies have been disabled for this discussion.