php - Catch and log fatal errors, warnings, notices in Zend Framework -


Currently I'm using a basic error controller that looks like this:

 < Code> class error controller expand My_MyController {public function error (action) {$ errors = $ this- & gt; _getParam ('error_handler'); Switch ($ errors-> type) {case Zend_Controller_Plugin_ErrorHandler :: EXCEPTION_Plugin_ErrorHandler :: Case Zend_Controller_Plugin_ErrorHandler :: EXCEPTION_NO_CONTROLLER: Case Zend_Controller_Plugin_ErrorHandler :: EXCEPTION_NO_ACTION: // 404 error - controller or action $$ not found- & gt; GetResponse () - & gt; SetRawHeader ('HTTP / 1.1 404 not found'); $ This- & gt; View- & gt; HeadTitle ('HTTP / 1.1 404 not found'); $ This- & gt; View- & gt; Message = 'HTTP / 1.1 404 not found'; break; Default: // Application error; Display error page, but do not change // status code // Exception log: $ exception = $ errors- & gt; exception; $ Log = new Zend_log (new zend_log_overter_stream (BASE_PATH. '/logs/applicationException.log')); $ Log- & gt; Debug ($ exception-> getMessage ()) "\ n". $ Exception-> GetTraceAsString ()); $ This- & gt; View- & gt; HeadTitle ('HTTP / 1.1 404 not found'); $ This- & gt; View- & gt; Message = 'app error'; break; } $ This- & gt; View- & gt; Exception = $ errors-> exception; }}  

This, however, only holds and logs only the application exceptions. It will not log any warning, notice and fatal errors.

I would like to log those people also what is the recommended way to do this in the error controller? Or should it be outside the ErrorController index.php (because the Zend Framework error handler only handles no root, missing application / exception exception and exception in the action controllers)?

Notices and warnings applications are not fatal (or not). Fatal errors are what they call on tin and sometimes can not be caught. But, if you really need it, then consider this:


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -