Reputation: 1888
I'm trying to log all application errors easily. Does ZendFramework have a plugin that can do this, or can it do this natively?
Upvotes: 2
Views: 5240
Reputation: 3614
To log all Error types (also PHP Fatal Error):
register_shutdown_function( 'myErrorHandler' );
function myErrorHandler() {
$error = error_get_last();
if( $error !== NULL) {
getMyZendLogger->log("got error: ".$error["message"], Zend_Log::ERR);
}
}
See How do I catch a PHP Fatal Error
Zend_Log::registerErrorHandler() (Zend-FW 1.12) catch not all errors
Upvotes: 0
Reputation: 4560
also you can use in your Controller
try{
} catch(Zend_Exception $e){
echo $e->getMessage
(or log errors in log file using Zend_Log)
}
Upvotes: 1
Reputation: 459
Type in your configuration:
phpSettings.log_errors = 1
phpSettings.error_log = "/path_to_yours_application_logs/php.log"
This puts all error logs to php.log file. It's common approach in production environment.
Upvotes: 6
Reputation: 6470
Zend includes standard error handling plugin that redirects to ErrorController. Here are 2 solutions:
Upvotes: 2