Forum Moderators: coopster

Message Too Old, No Replies

Ideas for error handling

need some ideas for PHP error handling techniques

         

lobo235

4:59 pm on Jun 17, 2005 (gmt 0)

10+ Year Member



I need some ideas for PHP error handling techniques. Ideally I would like to be able to log all PHP warnings and errors to a log file of my choice and receive an email each time there is an error or warning on any pages. Does anyone have any good ideas that they’ve implemented? I am curious to know what others do to make sure their PHP applications are error free and stable.

jatar_k

5:02 pm on Jun 17, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



we do a lot of qa and testing

we use syslog [php.net] to log everything we can

we have other logfiles we use for specific things like login attempts, data that didnt validate and anything else we want a specific history for.

all db errors are trapped to a single file and also get sent to my phone

hmm, testing, testing and more testing.

coopster

5:05 pm on Jun 17, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>> and also get sent to my phone

I meant to ask this before -- I'm assuming you are just emailing (text-messaging) your phone?

What types of db errors are you monitoring? Failed SQL calls, inserts, ...?

bennymack

5:09 pm on Jun 17, 2005 (gmt 0)

10+ Year Member




all db errors are trapped to a single file and also get sent to my phone

Wow you're serious! I thought you just had a dry sense of humor :\

jatar_k

5:10 pm on Jun 17, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



yep, text message set to a really grating ring

>> What types of db errors are you monitoring

any and all, there should never be one on production. A db error happens and I get the wake up call, doesn't matter if it's a bad select.

<added> very serious, it goes to me and the sysadmin as well and we check it out.

lobo235

5:23 pm on Jun 17, 2005 (gmt 0)

10+ Year Member



Yes, I am most concerned about Database errors. For example, if someone tries to create an account on my site and it fails for some reason or a payment is made by the customer and it doesn't get sent to the Database.

I took a quick look at the syslog() function and it looks like it may be what I need to use. So, the way I understand it this function needs you to supply the error message to it right? What happens if you want to log the actual PHP error message that has the line number, etc?

jatar_k

5:27 pm on Jun 17, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



yes

this may not be something that is available in a shared environment, then you could just setup a log of your own and write to that

lobo235

5:38 pm on Jun 17, 2005 (gmt 0)

10+ Year Member



I am currently running in a shared environment so what I need is a way to capture all php errors and warnings to a file of my choice. I don't want to supply the error message myself, I want it to log the error that php gives with the line number and built in error message. It looks like I will have to use set_error_handler() to accomplish this unless anyone knows a better way to do it.