从 apache error_log 中捞出东西是很痛苦的。有没有人指出一些更好的错误收集机制。类似于“使用 FogBUGZ 从用户获取崩溃报告 - 自动! ”中描述的内容,但对于 PHP/apache webapp
更具体地说,一些机制将 PHP 抛出的错误与某些错误跟踪软件挂钩。也许指向一些库/代码,这些库/代码捕获错误/警告并收集可以输入到错误跟踪软件的数据。具有以下奖励功能:
- 识别重复的错误。
- 如果错误导致多条错误消息,则应将其捕获为一个错误
从 apache error_log 中捞出东西是很痛苦的。有没有人指出一些更好的错误收集机制。类似于“使用 FogBUGZ 从用户获取崩溃报告 - 自动! ”中描述的内容,但对于 PHP/apache webapp
更具体地说,一些机制将 PHP 抛出的错误与某些错误跟踪软件挂钩。也许指向一些库/代码,这些库/代码捕获错误/警告并收集可以输入到错误跟踪软件的数据。具有以下奖励功能:
您可以指定自己的自定义 PHP 错误处理程序。这是一个简单的例子:
function log_error_handler($errno, $str, $file, $line)
{
switch($errno) {
case E_USER_ERROR:
add_log("PHP Error", "Error $errno on line $line in $file: $str", "fatal");
exit(1);
break;
case E_USER_WARNING:
add_log("PHP Warning", "Warning $errno on line $line in $file: $str", "warning");
break;
case E_USER_NOTICE:
add_log("PHP Notice", "Notice $errno on line $line in $file: $str", "note");
break;
default:
//uncomment this next line to catch
// add_log("PHP", "Unknown error $errno on line $line in $file: $str", "note");
break;
}
}
function add_log($code, $message, $type = 'message', $program = null ){
//do something like email the admin or enter in the data in to the bug tracking software db
}
// ### function to log php errors ####
set_error_handler("log_error_handler");
忽略错误发生的时间,获取错误信息的 md5 哈希。检查该 MD5 哈希是否已在您的错误数据库中。如果没有,请添加它。如果是,也许您想附加这次发生的日期。
- 如果错误导致多条错误消息,则应将其捕获为一个错误
这很棘手,除非您非常擅长使用该error_log()
功能。您可以就约定达成一致,例如:
error_log('ename:'.$error_name.' emessage:'.$e->toString());
这样您就可以解析出任何错误并将其分组为相同的ename
.MD5 和emessage
.
We're using Zend Platform on our servers. It's not free but works very well and does most of what you ask.
It allow your to define events and set triggers. When triggered the entire state of the application is logged. You can browse and filter graphs or lists of event types, mark events as duplicates, view source, etc.
The nicest thing is this: since the entire event is captures you can debug the event with a single click. The state of the application (code, session, variables, cookies, and even uploaded files) is sent to Eclipse and paused. You can then step through the code to see the exact state of the application when the bug occurred. Very useful for root cause analysis. If you want, you can replay the error on a development server, so you don't interfere with production.