perl2012
perl2012

Reputation: 149

How do I set logging priority in zend framework2?

I want to be able to control the logging priority in my zf2 application. I currently do

 $priority = \Zend\Log\Logger::INFO;
 $log->addWriter($writer, $priority);

to write to a log file, which works great. It just seems that the log level is stuck at Zend\Log\Logger::DEBUG no matter what I set $priority to.

Upvotes: 1

Views: 1115

Answers (1)

Oleg Lobach
Oleg Lobach

Reputation: 101

Can you clarify your question? Do you want to prioritize writers or limit messages priority?

If you want limit logging by message priority you must use Filter\Priority. Like this:

$writer = new \Zend\Log\Writer\Stream('/path/to/logfile');
$logger->addWriter($writer);

$filter = new \Zend\Log\Filter\Priority(Logger::CRIT);
$writer->addFilter($filter);

Upvotes: 2

Related Questions