473,671 Members | 2,475 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
6 1903
Hello BS,

To display the contents of the log file you could do a couple of different
things:

1Use a timer and display the contents every second (or so).
2Use a FileSystemWatch er - it is designed to listen to the file system
change notifications and raise events when a directory, or file in a
directory, changes.
3Use some other interprocess synchronization primative - probably overkill
for what you want to do.
--
brians
http://www.limbertech.com
"Aspiring .NET Programmer" 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 Brains

Thanks a lot for that information!
Yes. I did discover the 'filesystemwatc her' 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 FileSystemEvent Handler(OnChang ed);

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?

I havent explored the timer option yet. Any sample code that I may look
at?

Will be glad to provide any other info.

Thanks a lot for your time!
Suman

brians wrote:
Hello BS,

To display the contents of the log file you could do a couple of different
things:

1Use a timer and display the contents every second (or so).
2Use a FileSystemWatch er - it is designed to listen to the file system
change notifications and raise events when a directory, or file in a
directory, changes.
3Use some other interprocess synchronization primative - probably overkill
for what you want to do.
--
brians
http://www.limbertech.com
"Aspiring .NET Programmer" 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
Suman,

I'm not sure I understand your application design nor your use of the terms
"compile time" and "run time". Generally speaking, infinite loops and event
driven UI don't go well together.

The way I would monitor a file and display its contents is to use the
FileSystemWatch er object and in the changed event, update the display to
reflect the new contents. If you're in an infinite loop, your application
would never have a chance to update the display with the new contents of the
file.

In any event, you might want to look up on the Code Project at the following
link. The project sounds like just the ticket you're looking for:

http://www.codeproject.com/csharp/mk...ntswatcher.asp
--
brians
http://www.limbertech.com
"Aspiring .NET Programmer" wrote:
Hi Brains

Thanks a lot for that information!
Yes. I did discover the 'filesystemwatc her' 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 FileSystemEvent Handler(OnChang ed);

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?

I havent explored the timer option yet. Any sample code that I may look
at?

Will be glad to provide any other info.

Thanks a lot for your time!
Suman

brians wrote:
Hello BS,

To display the contents of the log file you could do a couple of different
things:

1Use a timer and display the contents every second (or so).
2Use a FileSystemWatch er - it is designed to listen to the file system
change notifications and raise events when a directory, or file in a
directory, changes.
3Use some other interprocess synchronization primative - probably overkill
for what you want to do.
--
brians
http://www.limbertech.com
"Aspiring .NET Programmer" 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 30 '06 #4
Hi Brian.
Thanks a lot for your help!!! I used a combination of the timer and the
FileSystemWache r technique to implement my solution. Thanks a lot once
agian. The example helped mee too!..and my apologies for not being able
to explain my second question properly.

Thanks and have a great day!
Suman

brians wrote:
Suman,

I'm not sure I understand your application design nor your use of the terms
"compile time" and "run time". Generally speaking, infinite loops and event
driven UI don't go well together.

The way I would monitor a file and display its contents is to use the
FileSystemWatch er object and in the changed event, update the display to
reflect the new contents. If you're in an infinite loop, your application
would never have a chance to update the display with the new contents of the
file.

In any event, you might want to look up on the Code Project at the following
link. The project sounds like just the ticket you're looking for:

http://www.codeproject.com/csharp/mk...ntswatcher.asp
--
brians
http://www.limbertech.com
"Aspiring .NET Programmer" wrote:
Hi Brains

Thanks a lot for that information!
Yes. I did discover the 'filesystemwatc her' 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 FileSystemEvent Handler(OnChang ed);

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?

I havent explored the timer option yet. Any sample code that I may look
at?

Will be glad to provide any other info.

Thanks a lot for your time!
Suman

brians wrote:
Hello BS,
>
To display the contents of the log file you could do a couple of different
things:
>
1Use a timer and display the contents every second (or so).
2Use a FileSystemWatch er - it is designed to listen to the file system
change notifications and raise events when a directory, or file in a
directory, changes.
3Use some other interprocess synchronization primative - probably overkill
for what you want to do.
--
brians
http://www.limbertech.com
>
>
"Aspiring .NET Programmer" 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
Oct 4 '06 #5
Hi Brian.
Thanks a lot for your help!!! I used a combination of the timer and the
FileSystemWache r technique to implement my solution. Thanks a lot once
agian. The example helped mee too!..and my apologies for not being able
to explain my second question properly.

Thanks and have a great day!
Suman

brians wrote:
Suman,

I'm not sure I understand your application design nor your use of the terms
"compile time" and "run time". Generally speaking, infinite loops and event
driven UI don't go well together.

The way I would monitor a file and display its contents is to use the
FileSystemWatch er object and in the changed event, update the display to
reflect the new contents. If you're in an infinite loop, your application
would never have a chance to update the display with the new contents of the
file.

In any event, you might want to look up on the Code Project at the following
link. The project sounds like just the ticket you're looking for:

http://www.codeproject.com/csharp/mk...ntswatcher.asp
--
brians
http://www.limbertech.com
"Aspiring .NET Programmer" wrote:
Hi Brains

Thanks a lot for that information!
Yes. I did discover the 'filesystemwatc her' 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 FileSystemEvent Handler(OnChang ed);

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?

I havent explored the timer option yet. Any sample code that I may look
at?

Will be glad to provide any other info.

Thanks a lot for your time!
Suman

brians wrote:
Hello BS,
>
To display the contents of the log file you could do a couple of different
things:
>
1Use a timer and display the contents every second (or so).
2Use a FileSystemWatch er - it is designed to listen to the file system
change notifications and raise events when a directory, or file in a
directory, changes.
3Use some other interprocess synchronization primative - probably overkill
for what you want to do.
--
brians
http://www.limbertech.com
>
>
"Aspiring .NET Programmer" 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
Oct 4 '06 #6
Hi Brian.
Thanks a lot for your help!!! I used a combination of the timer and the
FileSystemWache r technique to implement my solution. Thanks a lot once
agian. The example helped mee too!..and my apologies for not being able
to explain my second question properly.

Thanks and have a great day!
Suman

brians wrote:
Suman,

I'm not sure I understand your application design nor your use of the terms
"compile time" and "run time". Generally speaking, infinite loops and event
driven UI don't go well together.

The way I would monitor a file and display its contents is to use the
FileSystemWatch er object and in the changed event, update the display to
reflect the new contents. If you're in an infinite loop, your application
would never have a chance to update the display with the new contents of the
file.

In any event, you might want to look up on the Code Project at the following
link. The project sounds like just the ticket you're looking for:

http://www.codeproject.com/csharp/mk...ntswatcher.asp
--
brians
http://www.limbertech.com
"Aspiring .NET Programmer" wrote:
Hi Brains

Thanks a lot for that information!
Yes. I did discover the 'filesystemwatc her' 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 FileSystemEvent Handler(OnChang ed);

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?

I havent explored the timer option yet. Any sample code that I may look
at?

Will be glad to provide any other info.

Thanks a lot for your time!
Suman

brians wrote:
Hello BS,
>
To display the contents of the log file you could do a couple of different
things:
>
1Use a timer and display the contents every second (or so).
2Use a FileSystemWatch er - it is designed to listen to the file system
change notifications and raise events when a directory, or file in a
directory, changes.
3Use some other interprocess synchronization primative - probably overkill
for what you want to do.
--
brians
http://www.limbertech.com
>
>
"Aspiring .NET Programmer" 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
Oct 4 '06 #7

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

Similar topics

7
3124
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: /* Allocate 1st dimension */ if((Screen = (Atom ***) malloc(sizeof(Atom **) * Width)) == NULL) perrexit("malloc");
3
5727
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, and found HttpContext.Current.Server.Execute("mapage.aspx") but it executes the page where i call it, and not in the cell... i also tried something like that : MyTable.Rows(0).Cell(0).InnerHtml = Server.Execute("MaPage.aspx") but it doesn't...
27
13034
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 STATIC, i can have whatever size of data i want. but if the data (xml or text) is generated dynamically using php, then there seems to be a size limit! xmlhttprequest's responseText is truncated, and the xml therefore not well fromed. in border...
7
2418
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 with the timestamp the same down to the millisecond. Is this something I'm doing wrong?
1
2612
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. Included in the application program is a data “GRID” which I believe was created using Visual Basic, not standard Access. Its purpose is to display the results of a range of “from-to-dates” of registrations for different clients. The difficulty...
2
1942
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 system.' I'd understand if the MFT was keeping previous directory info, but the number above (140MB) seems typical for newly formatted drives. Google turned up mostly people complaining about this number continually growing, often using huge...
9
8853
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 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...
64
9709
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 buffer to dynamically grow using realloc(). A comment by Richard Heathfield in a thread here suggested that a good algorithm for this is to use realloc() to double the size of the buffer, but if realloc() fails request smaller size increments...
4
1913
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 appending that to a table, so if result set is large then browser struggles a lot to display and takes some time to display whole result in one shot. Instead of this if we can display the table as a growing table with rows displayed as and when rows...
30
26502
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 Tip came from one of our own resident Experts, mshmyob. In response to a Thread relating to this very Topic, mshmyob came up with a rather ingenious method to accomplish this task. He computed the Average Character Width of a String consisting of...
0
8481
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8400
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8924
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8823
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8602
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7441
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5702
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2058
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.