I'm registering a Zend\Log instance for exceptions, I will need all system errors emailed in the end, now it's just goes to a file. However, it doesn't work in controllers, the exception gets displayed in the view (or not, depending on display_exceptions
). I found this bug, no one seems to care about it much. So I need a workaround. Is there a way to make controllers not to eat my exceptions?
'service_manager' => array(
'factories' => array(
'Logger' => function ($sm) use ($sRootDir)
{
$log = new Zend\Log\Logger();
$writer = new Zend\Log\Writer\Stream($sRootDir . '/temp/license.log');
$log->addWriter($writer);
Zend\Log\Logger::registerErrorHandler($log);
Zend\Log\Logger::registerExceptionHandler($log);
return $log;
},
),
You can attach to the dispatch error event:
Module.php
An example service config for a simple logger
You can also log all exceptions in the stack to get a better idea of what went wrong down the line, rather than only showing the last exception, which may not include much information.