过滤器一个Filter对象阻塞一个消息被写入到日志. 对所有Writer过滤
要在所有writer之前过滤消息,你可以使用 $logger = new Zend_Log(); $writer = new Zend_Log_Writer_Stream('php://output'); $logger->addWriter($writer); $filter = new Zend_Log_Filter_Priority(Zend_Log::CRIT); $logger->addFilter($filter); // blocked $logger->info('Informational message'); // logged $logger->emerg('Emergency message'); 过滤一个Writer实例
要在一个特定的Writer上进行消息过滤,使用该Writer对象的 $logger = new Zend_Log(); $writer1 = new Zend_Log_Writer_Stream('/path/to/first/logfile'); $logger->addWriter($writer1); $writer2 = new Zend_Log_Writer_Stream('/path/to/second/logfile'); $logger->addWriter($writer2); // add a filter only to writer2 $filter = new Zend_Log_Filter_Priority(Zend_Log::CRIT); $writer2->addFilter($filter); // logged to writer1, blocked from writer2 $logger->info('Informational message'); // logged by both writers $logger->emerg('Emergency message');
|