how to write a log file

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm going to iterate over the rows of a datagrid.
The contents of a column are web addresses that I'm going to use in HTTP
requests.
Since this will most likely crash at some point, I'd like to write some sort
of log that would help me see where it stops working, rather than having to
go in manually and look at the downloaded files.

Anyone have any suggestions as to a good way to go about this, or any
favorite articles on the subject?

Thanks
 
Using System.Diagnostics;

EventLog logger= new EventLog();
logger.Source = "MySource";
logger.Log = "MyLog";
if(!EventLog.SourceExists("MySource"))
{EventLog.CreateEventSource("MySource", "MyLog"); }

try
{
//Code you wish to try
}
catch(Exception ex)
{
this.logger.WriteEntry("ex.Message");
}
 

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

Back
Top