Board index » delphi » Outputting Errors to Text File

Outputting Errors to Text File

I am a Delphi newbie (most of my recent work has been in Powerbuilder and
Cold Fusion).

We are using Delphi 4 with Sybase SQL Anywhere 5.5 as a back-end.

We want to capture all database and application errors (ahem...excuse me:
exceptions) and have the details of each written to a text file so that
the file can be sent to us for correction.  I know this will probably
involve the TApplication.OnException event.  Is it just as simple as
putting the output code in that event?  Will that capture the database
errors as well?  If not, how would I do that?

I'm not looking for someone to do this for me (well...that might not be
the absolute truth...), but if someone could give me a few tips, or point
me in the direction of an example or a good book, I'd appreciate it.

Thanks for your help,
Neil Dumont

 

Re:Outputting Errors to Text File


Neil,
  You are halfway there. In the OnException event handler of Application,
you could do this:

Var ErrorLog:Textfile;
        ErrorFile:string;
Begin
      ErrorFile:= 'C:\ApplicationErrors.txt';
     Assignfile(ErrorLog,'C:\ApplicationErrors.txt');
     if fileExists(errorFile) then Reset(ErrorLog)
      else
      Rewrite(Errorlog);
      Write(Errorlog,E.Message);
      Closefile(Errorlog);
end;

Good luck!!

--
David G. Parsons
(Dr. Delphi)
Inprise Certified Delphi 4 Client/Server Developer
Tekmetrics Certified Delphi Programmer
Tekmetrics Certified Visual Basic 5 Programmer
URL: http://www.DrDelphi.com
Email: DrDel...@DrDelphi.com
Voicemail/Fax: (603) 947-8207

Quote
Neil Dumont <ndum...@caci.com> wrote in message

news:MPG.12fa4e0a37d40efa989685@nnrp.digex.net...
Quote

> I am a Delphi newbie (most of my recent work has been in Powerbuilder and
> Cold Fusion).

> We are using Delphi 4 with Sybase SQL Anywhere 5.5 as a back-end.

> We want to capture all database and application errors (ahem...excuse me:
> exceptions) and have the details of each written to a text file so that
> the file can be sent to us for correction.  I know this will probably
> involve the TApplication.OnException event.  Is it just as simple as
> putting the output code in that event?  Will that capture the database
> errors as well?  If not, how would I do that?

> I'm not looking for someone to do this for me (well...that might not be
> the absolute truth...), but if someone could give me a few tips, or point
> me in the direction of an example or a good book, I'd appreciate it.

> Thanks for your help,
> Neil Dumont

Other Threads