I am getting error "Call to a member function add() on a non-object" on Kohana::$log
There is not log in application/logs
directory. The error I described is found on apache error_log
. This is how it appears
[Fri Aug 17 17:07:09 2012] [error] [client MY.IPA.DDR.ESS] PHP Fatal error: Call to a member function add() on a non-object in /var/www/html/application/classes/kohana/exception.php on line 8
This is my error controller.
<?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);
}
}
}
}
From the code it seems Kohana::$log
is not initialized yet. But this code was working for long time. Now what made it not working?
I am using Kohana-3.2 with PHP 5.3.13 on Fedora 15
I have solved this problem. If this problem occurs to any other kohana developer and he comes here from google here is the solution.
Run the following command from root shell. Remember if you reboot the server you'll have to run it again.
setsebool -P httpd_unified 1
Check these location
/var/log/messages
.If its SElinux issue you'll find log entry on /var/log/messages
. This is what I got.
setroubleshoot: SELinux is preventing /usr/sbin/httpd from write access on the directory /var/www/html/application/cache. For complete SELinux messages. run sealert -l 087dfdb5-c7de-4238-8e6b-a713213a456d
As stated running sealert -l 087dfdb5-c7de-4238-8e6b-a713213a456d
will reveal the command I wrote as solution.