I'm trying to log all application errors easily. Does ZendFramework have a plugin that can do this, or can it do this natively?
2
-
2possible duplicate of What is the best way to log errors in Zend Framework in my project at this stage?Colin Brock– Colin Brock2012-04-03 18:36:41 +00:00Commented Apr 3, 2012 at 18:36
-
github.com/markushausammann/monitorixmarkus– markus2012-04-03 21:24:36 +00:00Commented Apr 3, 2012 at 21:24
Add a comment
|
4 Answers
Zend includes standard error handling plugin that redirects to ErrorController. Here are 2 solutions:
- Create Zend_Controller_Plugin_ErrorHandler and register in bootstrap/controller
- Create custom PHP error handler
Comments
also you can use in your Controller
try{
} catch(Zend_Exception $e){
echo $e->getMessage
(or log errors in log file using Zend_Log)
}
Comments
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