Introduction to Zend Framework

 Learning Zend Framework

appendix

 Zend Framework Reference


  •  Zend_Gdata
  •  Zend_Http
  •  Zend_InfoCard
  •  Zend_Json
  •  Zend_Layout
  •  Zend_Ldap
  •  Zend_Loader
  •  Zend_Locale
  •  Zend_Log
  •  Zend_Mail
  •  Zend_Markup
  •  Zend_Measure
  •  Zend_Memory
  •  Zend_Mime
  •  Zend_Navigation
  •  Zend_Oauth
  •  Zend_OpenId
  •  Zend_Paginator
  •  Zend_Pdf
  •  Zend_ProgressBar
  •  Zend_Queue
  •  Zend_Reflection
  •  Zend_Registry
  •  Zend_Rest

  •  Zend_Search_Lucene
  •  Zend_Serializer
  •  Zend_Server
  •  Zend_Service
  •  Zend_Session
  •  Zend_Soap
  •  Zend_Tag
  •  Zend_Test
  •  Zend_Text
  •  Zend_TimeSync
  •  Zend_Tool
  •  Zend_Tool_Framework
  •  Zend_Tool_Project
  •  Zend_Translate
  •  Zend_Uri
  •  Zend_Validate
  •  Zend_Version
  •  Zend_View
  •  Zend_Wildfire
  •  Zend_XmlRpc
  • ZendX_Console_Process_Unix
  • ZendX_JQuery
  • Update 2011-11-16 - Revision 24438 - Version ZF 1.11.x

    44.4. Filters

    A Filter object blocks a message from being written to the log.

    44.4.1. Filtering for All Writers

    To filter before all writers, you can add any number of Filters to a Log object using the addFilter() method:

    $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');

    When you add one or more Filters to the Log object, the message must pass through all of the Filters before any Writers receives it.

    44.4.2. Filtering for a Writer Instance

    To filter only on a specific Writer instance, use the addFilter() method of that 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');
    digg delicious meneame google twitter technorati facebook

    Comments

    Loading...