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

  • version: $Revision: 1213283 $
  • since: 0.6

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

LoggerConfigurable
   |
   --LoggerFilter
      |
      --LoggerFilterLevelMatch
Variable Summary
Method Summary
integer decide (LoggerLoggingEvent $event)
void setAcceptOnMatch (boolean $acceptOnMatch)
void setLevelToMatch ( $level, string $l)
Variables
boolean $acceptOnMatch = true (line 54)

Indicates if this event should be accepted or denied on match

  • access: protected
LoggerLevel $levelToMatch (line 60)

The level, when to match

  • access: protected

Inherited Variables

Inherited from LoggerFilter

LoggerFilter::$next
Methods
decide (line 89)

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 ( $level, string $l)
  • string $l: the level to match
  • $level

Inherited Methods

Inherited From LoggerFilter

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

Inherited From LoggerConfigurable

LoggerConfigurable::setBoolean()
LoggerConfigurable::setFileSize()
LoggerConfigurable::setInteger()
LoggerConfigurable::setLevel()
LoggerConfigurable::setNumeric()
LoggerConfigurable::setPositiveInteger()
LoggerConfigurable::setString()
LoggerConfigurable::warn()
Class Constants

Documentation generated on Sat, 18 Feb 2012 22:32:24 +0000 by phpDocumentor 1.4.3