Class StatusConsoleListener

  • All Implemented Interfaces:
    Closeable, AutoCloseable, EventListener, org.apache.logging.log4j.status.StatusListener

    public class StatusConsoleListener
    extends Object
    implements org.apache.logging.log4j.status.StatusListener
    A StatusListener that writes to the console.
    • Constructor Detail

      • StatusConsoleListener

        public StatusConsoleListener​(org.apache.logging.log4j.Level level)
        Constructs a StatusConsoleListener instance writing to System.out using the supplied level.
        Parameters:
        level - the level of status messages that should appear on the console
        Throws:
        NullPointerException - on null level
      • StatusConsoleListener

        public StatusConsoleListener​(org.apache.logging.log4j.Level level,
                                     PrintStream stream)
        Constructs a StatusConsoleListener instance using the supplied level and stream.

        Make sure not to use a logger stream of some sort to avoid creating an infinite loop of indirection!

        Parameters:
        level - the level of status messages that should appear on the console
        stream - the stream to write to
        Throws:
        NullPointerException - on null level or stream
    • Method Detail

      • setLevel

        public void setLevel​(org.apache.logging.log4j.Level level)
        Sets the level to a new value.
        Parameters:
        level - the new level
        Throws:
        NullPointerException - on null level
      • setStream

        public void setStream​(PrintStream stream)
        Sets the output stream to a new value.
        Parameters:
        stream - the new output stream
        Throws:
        NullPointerException - on null stream
        Since:
        2.23.0
      • getStatusLevel

        public org.apache.logging.log4j.Level getStatusLevel()
        Returns the level for which the listener should receive events.
        Specified by:
        getStatusLevel in interface org.apache.logging.log4j.status.StatusListener
        Returns:
        the log level
      • log

        public void log​(StatusData data)
        Writes status messages to the console.
        Specified by:
        log in interface org.apache.logging.log4j.status.StatusListener
        Parameters:
        data - a status data
        Throws:
        NullPointerException - on null data
      • setFilters

        @Deprecated
        public void setFilters​(String... filters)
        Deprecated.
        since 2.23.0, this method is ineffective and only kept for binary backward compatibility.
        Adds package name filters to exclude.
        Parameters:
        filters - An array of package names to exclude.
      • close

        public void close()
        Resets the level and output stream to its initial values, and closes the output stream, if it is a non-system one.
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable