2

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

4 Answers 4

6

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.

Sign up to request clarification or add additional context in comments.

Comments

2

Zend includes standard error handling plugin that redirects to ErrorController. Here are 2 solutions:

  1. Create Zend_Controller_Plugin_ErrorHandler and register in bootstrap/controller
  2. Create custom PHP error handler

Comments

1

also you can use in your Controller

try{
} catch(Zend_Exception $e){
    echo $e->getMessage
    (or log errors in log file using Zend_Log) 
}

Zend_Log

Zend_Exception

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.