how to write a log file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • a

    #1

    how to write a log file

    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
  • CodeRazor

    #2
    RE: how to write a log file

    Using System.Diagnost ics;

    EventLog logger= new EventLog();
    logger.Source = "MySource";
    logger.Log = "MyLog";
    if(!EventLog.So urceExists("MyS ource"))
    {EventLog.Creat eEventSource("M ySource", "MyLog"); }

    try
    {
    //Code you wish to try
    }
    catch(Exception ex)
    {
    this.logger.Wri teEntry("ex.Mes sage");
    }



    "a" wrote:
    [color=blue]
    > 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[/color]

    Comment

    • Marc Jennings

      #3
      Re: how to write a log file

      Remove the quotes from around ex.Message, though. ;-)

      On Wed, 1 Jun 2005 00:46:05 -0700, CodeRazor
      <CodeRazor@disc ussions.microso ft.com> wrote:
      [color=blue]
      >Using System.Diagnost ics;
      >
      >EventLog logger= new EventLog();
      >logger.Sourc e = "MySource";
      >logger.Log = "MyLog";
      >if(!EventLog.S ourceExists("My Source"))
      >{EventLog.Crea teEventSource(" MySource", "MyLog"); }
      >
      >try
      >{
      >//Code you wish to try
      >}
      >catch(Exceptio n ex)
      >{
      >this.logger.Wr iteEntry("ex.Me ssage");
      >}
      >
      >
      >
      >"a" wrote:
      >[color=green]
      >> 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[/color][/color]

      Comment

      Working...