Class AppenderWrapper

  • All Implemented Interfaces:
    Appender, AppenderAttachable

    public class AppenderWrapper
    extends AppenderAttachableImpl
    implements Appender
    Holds a Log4j 2 Appender in an empty Log4j 1 Appender so it can be extracted when constructing the configuration. Allows a Log4j 1 Appender to reference a Log4j 2 Appender.
    • Constructor Detail

      • AppenderWrapper

        public AppenderWrapper​(Appender appender)
    • Method Detail

      • getAppender

        public Appender getAppender()
      • addFilter

        public void addFilter​(Filter newFilter)
        Description copied from interface: Appender
        Add a filter to the end of the filter list.
        Specified by:
        addFilter in interface Appender
        Parameters:
        newFilter - The filter to add.
      • getFilter

        public Filter getFilter()
        Description copied from interface: Appender
        Returns the head Filter. The Filters are organized in a linked list and so all Filters on this Appender are available through the result.
        Specified by:
        getFilter in interface Appender
        Returns:
        the head Filter or null, if no Filters are present
      • clearFilters

        public void clearFilters()
        Description copied from interface: Appender
        Clear the list of filters by removing all the filters in it.
        Specified by:
        clearFilters in interface Appender
      • close

        public void close()
        Description copied from interface: Appender
        Release any resources allocated within the appender such as file handles, network connections, etc.

        It is a programming error to append to a closed appender.

        Specified by:
        close in interface Appender
        Overrides:
        close in class AppenderAttachableImpl
      • doAppend

        public void doAppend​(LoggingEvent event)
        Description copied from interface: Appender
        Log in Appender specific way. When appropriate, Loggers will call the doAppend method of appender implementations in order to log.
        Specified by:
        doAppend in interface Appender
        Parameters:
        event - The LoggingEvent.
      • getName

        public String getName()
        Description copied from interface: Appender
        Get the name of this appender.
        Specified by:
        getName in interface Appender
        Returns:
        name, may be null.
      • setLayout

        public void setLayout​(Layout layout)
        Description copied from interface: Appender
        Set the Layout for this appender.
        Specified by:
        setLayout in interface Appender
        Parameters:
        layout - The Layout.
      • getLayout

        public Layout getLayout()
        Description copied from interface: Appender
        Returns this appenders layout.
        Specified by:
        getLayout in interface Appender
        Returns:
        the Layout.
      • setName

        public void setName​(String name)
        Description copied from interface: Appender
        Set the name of this appender. The name is used by other components to identify this appender.
        Specified by:
        setName in interface Appender
        Parameters:
        name - The appender name.
      • requiresLayout

        public boolean requiresLayout()
        Description copied from interface: Appender
        Configurators call this method to determine if the appender requires a layout. If this method returns true, meaning that layout is required, then the configurator will configure an layout using the configuration information at its disposal. If this method returns false, meaning that a layout is not required, then layout configuration will be skipped even if there is available layout configuration information at the disposal of the configurator..

        In the rather exceptional case, where the appender implementation admits a layout but can also work without it, then the appender should return true.

        Specified by:
        requiresLayout in interface Appender
        Returns:
        true if a Layout is required.