In my recent zf2 (zend framework 2.1) project module I defined a logger with a stream writer and a firephp writer. I am using the same module also for some console requests (Zend\Console). The problem I had was that the system complains of the firephp logger when I did a console request:
====================================================================== The application has thrown an exception! ====================================================================== Exception Headers already sent in C:\...\Zend\Console\Adapter\AbstractAdapter.php on line 56. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive. ----------------------------------------------------------------------
Short: Cannot send log data to FirePHP.
So I changed my local.php file to differentiate between a HTTP request and a console request.
This is the important part of the service_manager/factories configuration:
'Zend\Log\Logger' => function($sm) { $request = $sm->get('Request'); $logger = new \Zend\Log\Logger(); if ($request instanceof Zend\Console\Request) { $file = new \Zend\Log\Writer\Stream(__DIR__ . '/../../data/dev-console.log'); $logger->addWriter($file); } else { $writer_firebug = new \Zend\Log\Writer\FirePhp(); $writer_stream = new \Zend\Log\Writer\Stream(__DIR__ . '/../../data/dev.log'); $logger->addWriter($writer_firebug); $logger->addWriter($writer_stream); } return $logger; }