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?

Sugitime
  • 1,818
  • 4
  • 23
  • 44
  • 2
    possible duplicate of [What is the best way to log errors in Zend Framework in my project at this stage?](http://stackoverflow.com/questions/2450842/what-is-the-best-way-to-log-errors-in-zend-framework-in-my-project-at-this-stage) – Colin Brock Apr 03 '12 at 18:36
  • https://github.com/markushausammann/monitorix – markus Apr 03 '12 at 21:24

4 Answers4

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.

Artur Michalak
  • 459
  • 3
  • 6
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
Alex
  • 6,441
  • 2
  • 25
  • 26
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

RDK
  • 4,540
  • 2
  • 20
  • 29
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

Community
  • 1
  • 1
es cologne
  • 3,318
  • 2
  • 17
  • 11