473,387 Members | 1,771 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,387 software developers and data experts.

How to dynamically display entries made into a growing log file

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
2 1918

Hi Suman,

The 'filesystemwatcher' windows control does exactly this. You point this
windows control to a file and it will fire events whenever the file changes
(i.e. modifications etc.). You can then re-read the file (or do whatever) to
refresh your display of information. Yes - windows forms is a good mechanism
to accomplish this.

In fact Microsoft has even anticipated applications needing to do this. If
you create a Windows Form in VS 2005 and call up your SERVER EXPLORER. Click
on your machine (machine name in server explorer) and you will see a tree
node that points to the EVENT LOGS. Just drag an event log over to your form
and drop it on your form. VS 2005 will automatically create a
'filesystemwatcher' control on your form pointing directly to the event log
you just dragged. Works very nicely and 'bingo' you have a
'filesystemwatcher' set up exactly to do what you want to do.

--
Franklin M. Gauer III
Applications Development Manager
Integrated Companies, Inc.
"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 #2
Hi Franklin,

Thanks a lot for that information!
Yes. I did discover the 'filesystemwatcher' class earlier. And was
working on that while I posted my query.

My problem while using that is that the following statement:

watcher.Changed += new FileSystemEventHandler(OnChanged);

does pick up events that may happen at compile time. That is if I have
a break point on the above line and put the statement in a finite loop
and start compiling, stop at one of the break point and go change the
log file i am pointing to and then coninue the next iteration of the
loop, it does identify the modification and calls the delegated method.
However, the appropriate output is only displayed once the compilation
has finished. Now, I need an application that continuosly monitors the
logfile and as and when it identifies any modification in it, displays
the log files contents on the windows form.

Basically need to "file changed" event captured at runtime and not
compile time. If I put the above loop in an infinite loop, obviously
the compilation never ends and I just see a blank form. :(

Am I missing something here?

Will be glad to provide any other info.

Thanks a lot for your time!
Suman
Franklin M. Gauer III wrote:
Hi Suman,

The 'filesystemwatcher' windows control does exactly this. You point this
windows control to a file and it will fire events whenever the file changes
(i.e. modifications etc.). You can then re-read the file (or do whatever) to
refresh your display of information. Yes - windows forms is a good mechanism
to accomplish this.

In fact Microsoft has even anticipated applications needing to do this. If
you create a Windows Form in VS 2005 and call up your SERVER EXPLORER. Click
on your machine (machine name in server explorer) and you will see a tree
node that points to the EVENT LOGS. Just drag an event log over to your form
and drop it on your form. VS 2005 will automatically create a
'filesystemwatcher' control on your form pointing directly to the event log
you just dragged. Works very nicely and 'bingo' you have a
'filesystemwatcher' set up exactly to do what you want to do.

--
Franklin M. Gauer III
Applications Development Manager
Integrated Companies, Inc.
"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 #3

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

Similar topics

7
by: Fabian Wauthier | last post by:
Hi list, I am trying to dynamically grow a 2 dimensional array (Atom ***Screen) of pointers to a struct Atom (i.e. the head of a linked list). I am not sure if this is the right way to do it: ...
3
by: Quentin | last post by:
Hey there ! I made my own WebControl, that inherits from WebControls, and i added an HtmlTable to it. I would like to include a file, dynamically, to one of its cells... I've already searched,...
27
by: ted benedict | last post by:
hi everybody, i hope this is the right place to discuss this weird behaviour. i am getting dynamically generated text or xml from the server side using xmlhttprequest. if the server side data is...
7
by: Jed Parsons | last post by:
Hi, I'm using the logging module for the first time. I'm using it from within Zope Extensions. My problem is that, for every event logged, the logger is producing multiple identical entries...
1
by: John Phelan-Cummings | last post by:
When I add the name of a new individual in a, bound form, it will not display that person’s name in a label control of a second unbound form. I have a scheduling program that I am working on. ...
2
by: _DD | last post by:
File system question. Even expert config-techies don't seem to know this, but one of the local OS experts will: Chkdsk, on a newly formatted partition, often says "140000KB in use by the...
9
by: Suman | last post by:
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...
64
by: Philip Potter | last post by:
Hello clc, I have a buffer in a program which I write to. The buffer has write-only, unsigned-char-at-a-time access, and the amount of space required isn't known a priori. Therefore I want the...
4
by: xoinki | last post by:
hi all, I have a content which is fetched from a JSON response. I am putting that in a dynamic table and showing the data. The problem with this approach is, I am adding row by row and finally...
30
ADezii
by: ADezii | last post by:
This week’s Tip of the Week will clearly demonstrate how you can dynamically set the Drop Down List Width of a Combo Box to the length of the longest item in its Row Source. The inspiration for this...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...

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.