Class LoggerFilterLevelMatch

Description

This is a very simple filter based on level matching.

The filter admits two options <var>LevelToMatch</var> and <var>AcceptOnMatch</var>. If there is an exact match between the value of the <var>LevelToMatch</var> option and the level of the LoggerLoggingEvent, then the decide() method returns LoggerFilter::ACCEPT in case the <var>AcceptOnMatch</var> option value is set to true, if it is false then LoggerFilter::DENY is returned. If there is no match, LoggerFilter::NEUTRAL is returned.

An example for this filter:

  1. require_once dirname(__FILE__).'/../../main/php/Logger.php';
  2.  
  3. Logger::configure(dirname(__FILE__).'/../resources/filter_levelmatch.xml');
  4. $logger Logger::getRootLogger();
  5. $logger->debug("Matching and will be rejected");
  6. $logger->info("Not matching and will be accepted");

The corresponding XML file:

  1. <log4php:configuration
  2.   xmlns:log4php="http://logging.apache.org/log4php/"
  3.   threshold="all" debug="false">
  4.     <appender name="default" class="LoggerAppenderEcho">
  5.         <layout class="LoggerLayoutTTCC"/>
  6.         <filter class="LoggerFilterLevelMatch">
  7.             <param name="LevelToMatch" value="DEBUG" />
  8.             <param name="AcceptOnMatch" value="false" />
  9.         </filter>
  10.     </appender>
  11.     <root>
  12.         <level value="DEBUG" />
  13.         <appender_ref ref="default" />
  14.     </root>
  15. </log4php:configuration>

  • version: $Revision: 883108 $
  • since: 0.6

Located in /filters/LoggerFilterLevelMatch.php (line 48)

LoggerFilter
   |
   --LoggerFilterLevelMatch
Method Summary
integer decide (LoggerLoggingEvent $event)
void setAcceptOnMatch (boolean $acceptOnMatch)
void setLevelToMatch (string $l)
Variables

Inherited Variables

Inherited from LoggerFilter

LoggerFilter::$next
Methods
decide (line 93)

Return the decision of this filter.

Returns LoggerFilter::NEUTRAL if the <var>LevelToMatch</var> option is not set or if there is not match. Otherwise, if there is a match, then the returned decision is LoggerFilter::ACCEPT if the <var>AcceptOnMatch</var> property is set to true. The returned decision is LoggerFilter::DENY if the <var>AcceptOnMatch</var> property is set to false.

  • access: public
integer decide (LoggerLoggingEvent $event)

Redefinition of:
LoggerFilter::decide()
Decide what to do.
setAcceptOnMatch (line 65)
  • access: public
void setAcceptOnMatch (boolean $acceptOnMatch)
  • boolean $acceptOnMatch
setLevelToMatch (line 72)
  • access: public
void setLevelToMatch (string $l)
  • string $l: the level to match

Inherited Methods

Inherited From LoggerFilter

LoggerFilter::activateOptions()
LoggerFilter::addNext()
LoggerFilter::decide()
LoggerFilter::getNext()
Class Constants

Documentation generated on Fri, 27 Nov 2009 07:44:49 +0100 by phpDocumentor 1.4.3