Class Receiver

  • All Implemented Interfaces:
    Plugin, Component, org.apache.log4j.spi.OptionHandler, Thresholdable
    Direct Known Subclasses:
    CustomSQLDBReceiver, DBReceiver, Generator, JMSReceiver, LogFilePatternReceiver, LogFileXMLReceiver, MulticastReceiver, UDPReceiver, XMLSocketReceiver

    public abstract class Receiver
    extends PluginSkeleton
    implements Thresholdable
    Defines the base class for Receiver plugins.

    Just as Appenders send logging events outside of the log4j environment (to files, to smtp, to sockets, etc), Receivers bring logging events inside the log4j environment.

    Receivers are meant to support the receiving of remote logging events from another process.

    Receivers can also be used to "import" log messages from other logging packages into the log4j environment.

    Receivers can be configured to post events to a given LoggerRepository.

    Subclasses of Receiver must implement the isActive(), activateOptions(), and shutdown() methods. The doPost() method is provided to standardize the "import" of remote events into the repository.

    Author:
    Mark Womack, Ceki Gülcü, Paul Smith (psmith@apache.org)
    • Field Detail

      • thresholdLevel

        protected org.apache.log4j.Level thresholdLevel
        Threshold level.
    • Constructor Detail

      • Receiver

        protected Receiver()
        Create new instance.
    • Method Detail

      • setThreshold

        public void setThreshold​(org.apache.log4j.Level level)
        Sets the receiver theshold to the given level.
        Specified by:
        setThreshold in interface Thresholdable
        Parameters:
        level - The threshold level events must equal or be greater than before further processing can be done.
      • getThreshold

        public org.apache.log4j.Level getThreshold()
        Gets the current threshold setting of the receiver.
        Specified by:
        getThreshold in interface Thresholdable
        Returns:
        Level The current threshold level of the receiver.
      • isAsSevereAsThreshold

        public boolean isAsSevereAsThreshold​(org.apache.log4j.Level level)
        Returns true if the given level is equals or greater than the current threshold value of the receiver.
        Specified by:
        isAsSevereAsThreshold in interface Thresholdable
        Parameters:
        level - The level to test against the receiver threshold.
        Returns:
        boolean True if level is equal or greater than the receiver threshold.
      • doPost

        public void doPost​(org.apache.log4j.spi.LoggingEvent event)
        Posts the logging event to a logger in the configured logger repository.
        Parameters:
        event - the log event to post to the local log4j environment.