Open notepad

D

Daniel

Hi

I have a server programme and it writes any errors quietly to a logfile so
that the server keeps running and only dies on a critical problem. I'd like
to have a menu item saying View Log that i can click and it will open my
logfile in notepad (any better alternative methods for viewing a log please
let me know).

Does anyone know how to do this? Or would it be easier to make my own form
and just open the file myself and write the contents to the form?

Thanks in advance
 
M

Marc Gravell

Well, personally I would develop this as a service, but that is
by-the-by. However, for logging, have you considered the event-log?
This is a well understood, well supported framework that supports
remote monitoring etc. You can create your own logs to segregate your
data from the OS's...

And from a UI you can either start the eventvwr.exe (a shim to MMC
these days), or you can query the event-log via the managed API to
display it.

Marc
 
B

Bobbo

Daniel said:
I have a server programme and it writes any errors quietly to a logfile so
that the server keeps running and only dies on a critical problem. I'd like
to have a menu item saying View Log that i can click and it will open my
logfile in notepad (any better alternative methods for viewing a log please
let me know).

Take a look at the System.Diagnostics.ProcessStartInfo class.

Personally I'd have it use the name of the log as the process filename,
rather than "notepad.exe <logfile.txt>" because that way it should use
the user's registered application associated with .txt files if they've
changed this, rather than forcing them to use notepad.

http://msdn2.microsoft.com/en-us/library/system.diagnostics.processstartinfo(VS.80).aspx
 
D

Daniel

I considered that yes but it hought its such a simple need at the moment.
Maybe you are right thats best i just thought possibly a bit of overkill to
do that. I like the idea of having my log separate from anything else
getting logged by event log.
 
D

Duggi

The following code should work opening the logfile with the application
that the client machine registered with.

{
System.Diagnostics.ProcessStartInfo pi = new
System.Diagnostics.ProcessStartInfo(@"C:\log.txt"); // log file file
path
System.Diagnostics.Process.Start(pi);
}

and for logging the famous log4net is available.

Thanks
-Srinivas.
 
M

Marc Gravell

Simpler (given no other properties used):

System.Diagnostics.Process.Start(@"C:\log.txt"");

Marc
 
S

Shailen Sukul

Have a look at NLog as well.
If you are after simplicity, then it is the simplest API to use in my
opinion.

My personal preference is to log to a database table so that the user can do
various searches across the log as well as sorting.

--
With Regards
Shailen Sukul
..Net Architect
(MCPD: Ent Apps, MCSD.Net MCSD MCAD)
Ashlen Consulting Services
http://www.ashlen.net.au
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top