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");
}
 
Back
Top