【发布时间】:2012-08-17 22:21:33
【问题描述】:
我在 Kohana::$log 上收到错误“调用非对象上的成员函数 add()”
application/logs目录没有登录。我描述的错误在 apache error_log 上找到。它是这样出现的
[Fri Aug 17 17:07:09 2012] [error] [client MY.IPA.DDR.ESS] PHP 致命错误:在 /var/www/ 中的非对象上调用成员函数 add()第 8 行的 html/application/classes/kohana/exception.php
这是我的错误控制器。
<?php
class Kohana_Exception extends Kohana_Kohana_Exception {
public static function handler(Exception $e) {
if (Kohana::DEVELOPMENT === Kohana::$environment) {
parent::handler($e);
} else {
try {
Kohana::$log->add(Log::ERROR, "own exception handler");
Kohana::$log->add(Log::ERROR, parent::text($e));
$attributes = array('action' => 500, 'message' => rawurlencode($e->getMessage()));
if ($e instanceof HTTP_Exception) {
$attributes['action'] = $e->getCode();
}
// Error sub-request.
echo Request::factory(Route::get('error')->uri($attributes))->execute()->send_headers()->body();
}
catch(Exception $e) {
// Clean the output buffer if one exists
ob_get_level() and ob_clean();
// Display the exception text
echo parent::text($e);
// Exit with an error status
exit(1);
}
}
}
}
从代码看来Kohana::$log 尚未初始化。但是这段代码工作了很长时间。现在是什么让它不起作用?
我在 Fedora 15 上使用 Kohana-3.2 和 PHP 5.3.13
【问题讨论】:
-
5 个月后,我在同一个文件上遇到了同样的错误!我在谷歌上搜索导致了我自己的问题:o
标签: php error-handling kohana fatal-error