Sanjay Khatri
Sanjay Khatri

Reputation: 4211

php error tracking

i am using php and mysql for my projects with pear package.

i want to track bugs in my programs .

is there any way to track a bug in pear package or php5.

suppose in my program any error or warning is generate then i want to track this error and

store into database.

any one have idea about it.

thanks in advance.

Upvotes: 3

Views: 2991

Answers (5)

morrislaptop
morrislaptop

Reputation: 1131

I've written a powerful error tracking library which allows you to track errors in your application using a single API to any or all of services like Exceptiontrap, Sentry, Raygun, Airbrake AND local resources like logs, emails, databases and FirePHP. Check it

Upvotes: 0

tbuehl
tbuehl

Reputation: 178

Instead of storing the error details into your own database you should use an error tracking service.

The problem of tracking your own errors in the same system is problematic: The chances are high that it cannot store them, because of the same reason the error occurred itself. Like the database has a deadlock or other errors. Parsing your log file may be ok, but you would only know about the error with a big delay and probably miss valuable information.

Some other advantages:

  • It groups the errors to similar error groups
  • You will be notified about new errors in real-time
  • You see how often and when an error occurred

I'm the founder of Exceptiontrap with its PHP library, but there are other services, too.

Upvotes: 1

dan-klasson
dan-klasson

Reputation: 14190

There is Sentry. It's written in Python, but you could write a PHP client for it. I couldn't find one myself, so please lemme know if you find/code one.

Upvotes: 0

Your Common Sense
Your Common Sense

Reputation: 157887

Do not store errors in the database. many errors are database related itself. what would you do with it?

PHP already have everything you want. just turn on log_errors ini directive and, optionally, error_log one to specify certain log file instead of placing PHP errors in the web-server's log file

Also you may find useful a trigger_error() function which could bring a custom message to the standard error output, e.g

mysql_error($sql);
if(!$sql) trigger_error(mysql_error()." in ".$sql);

Upvotes: 6

Igor Zinov'yev
Igor Zinov'yev

Reputation: 3706

If you want to find bugs faster, you should consider using xdebug. It provides more output on errors and allows you to debug the application step-by-step.

If you need to log exceptions, you can use some logger, like Zend_Log, to write logs with specific application data. You can even specify message importance level to leave out debug data on production systems.

Also, I would recommend using Firebug together with Firephp. This way you can get debug data easily without using print_r and the likes.

Upvotes: 0

Related Questions