Answer the question
In order to leave comments, you need to log in
How to make Logger catch exceptions in ZF2?
Inside the onBootstrap module I create a logger:
use Zend\Log\Writer\Stream as LogWriterStream;
use Zend\Log\Formatter\Simple as LogFormatter;
$logger = new Logger(array(
'exceptionhandler' => true,
'errorhandler' => true,
'fatal_error_shutdownfunction' => true,
));
$filepath = './data/logs/php/' . date('Y-m-d') . '.log';
$writer = new LogWriterStream($filepath);
$formatter = new LogFormatter(null, 'd.m.Y H:i:s');
$writer->setFormatter($formatter);
$logger->addWriter($writer);
Answer the question
In order to leave comments, you need to log in
Can you give an example of an exception? Some exceptions are not caught at all...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question