Class AbstractPropertyFilter

  • Direct Known Subclasses:
    JndiPropertyFilter

    @Deprecated
    public abstract class AbstractPropertyFilter
    extends org.apache.log4j.spi.Filter
    Deprecated.
    since the switch to Log4j2 in CMS v12. Instead use LookupFilter which is log4j2 based.
    AbstractPropertyFilter (Log4j1)

    Abstract log4j filter base class which can be extended for specific property based logging event filtering. This abstract class provides three base properties, name, value and onMatchOption.

    This abstract filter base class compares the runtime property value with the specified property value by invoking the abstract getProperty(LoggingEvent, String) method. Therefore, derived classes can implement the getProperty(LoggingEvent, String) method to read runtime properties from any environments such as Log4j MDC, JNDI resources, etc.

    The 'name' property is for specifying a property name, and the 'value' property is for specifying a property value to be compared with the real property value at runtime. Finally, the 'onMatchOption' property is for specifying the behavior when the property is matched. The 'onMatchOption' property can be set to either 'ACCEPT' (Filter.ACCEPT) or 'DENY' (Filter.DENY).

    If the 'onMatchOption' is set to 'ACCEPT', then the logging even will be accepted when the runtime property value matches with the specified property value. In this case, the logging event will be rejected if the runtime property value doesn't match.

    If the 'onMatchOption' is set to 'DENY', then the logging event will be rejected when the runtime property value matches with the specified property value. In this case, the logging event will be accepted when the runtime property value doesn't match.

    See Also:
    Filter
    • Field Summary

      • Fields inherited from class org.apache.log4j.spi.Filter

        ACCEPT, DENY, NEUTRAL, next
    • Constructor Detail

      • AbstractPropertyFilter

        public AbstractPropertyFilter()
        Deprecated.
    • Method Detail

      • decide

        public int decide​(org.apache.log4j.spi.LoggingEvent event)
        Deprecated.
        Specified by:
        decide in class org.apache.log4j.spi.Filter
      • getName

        public String getName()
        Deprecated.
        The property name on which to filter.
        Returns:
        property name on which to filter
      • setName

        public void setName​(String name)
        Deprecated.
        Sets the property name on which to filter.
        Parameters:
        name - the property name on which to filter
      • getValue

        public String getValue()
        Deprecated.
        Gets the value to match.
        Returns:
        the value to match.
      • setValue

        public void setValue​(String value)
        Deprecated.
        Sets the value to match.
        Parameters:
        value - the value to match.
      • getOnMatch

        public int getOnMatch()
        Deprecated.
        Returns the deciding option whether or not the log message should be logged if a match is found.
        See Also:
        Filter.ACCEPT, Filter.DENY
      • setOnMatch

        public void setOnMatch​(int onMatch)
        Deprecated.
        Sets the deciding option whether or not the log message should be logged. Allowed option is either Filter.ACCEPT or Filter.DENY.
        Parameters:
        onMatch -
        See Also:
        Filter.ACCEPT, Filter.DENY
      • getOnMatchOption

        public String getOnMatchOption()
        Deprecated.
        Returns string representation of the option flag whether or not the log message should be logged if a match is found.
        See Also:
        Filter.ACCEPT, Filter.DENY
      • setOnMatchOption

        public void setOnMatchOption​(String onMatchOption)
        Deprecated.
        Sets string representation of the option flag whether or not the log message should be logged. Allowed option is either 'ACCEPT' or 'DENY'.
        Parameters:
        onMatchOption -
        See Also:
        Filter.ACCEPT, Filter.DENY
      • getProperty

        protected abstract String getProperty​(org.apache.log4j.spi.LoggingEvent event,
                                              String name)
        Deprecated.
        Finds the property value by the name from the underlying environment.
        Parameters:
        event -
        name -