Package org.apache.logging.log4j.status
Class StatusConsoleListener
- java.lang.Object
-
- org.apache.logging.log4j.status.StatusConsoleListener
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,java.util.EventListener,StatusListener
public class StatusConsoleListener extends java.lang.Object implements StatusListener
AStatusListenerthat writes to the console.
-
-
Field Summary
Fields Modifier and Type Field Description private LevelinitialLevelprivate java.io.PrintStreaminitialStreamprivate Levellevelprivate java.util.concurrent.locks.Locklockprivate java.io.PrintStreamstream
-
Constructor Summary
Constructors Constructor Description StatusConsoleListener(Level level)Constructs aStatusConsoleListenerinstance writing toSystem.outusing the supplied level.StatusConsoleListener(Level level, java.io.PrintStream stream)Constructs aStatusConsoleListenerinstance using the supplied level and stream.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidclose()Resets the level and output stream to its initial values, and closes the output stream, if it is a non-system one.private static voidcloseNonSystemStream(java.io.OutputStream stream)LevelgetStatusLevel()Returns the level for which the listener should receive events.voidlog(StatusData data)Writes status messages to the console.voidsetFilters(java.lang.String... filters)Deprecated.since 2.23.0, this method is ineffective and only kept for binary backward compatibility.voidsetLevel(Level level)Sets the level to a new value.voidsetStream(java.io.PrintStream stream)Sets the output stream to a new value.
-
-
-
Constructor Detail
-
StatusConsoleListener
public StatusConsoleListener(Level level)
Constructs aStatusConsoleListenerinstance writing toSystem.outusing the supplied level.- Parameters:
level- the level of status messages that should appear on the console- Throws:
java.lang.NullPointerException- on nulllevel
-
StatusConsoleListener
public StatusConsoleListener(Level level, java.io.PrintStream stream)
Constructs aStatusConsoleListenerinstance 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 consolestream- the stream to write to- Throws:
java.lang.NullPointerException- on nulllevelorstream
-
-
Method Detail
-
setLevel
public void setLevel(Level level)
Sets the level to a new value.- Parameters:
level- the new level- Throws:
java.lang.NullPointerException- on nulllevel
-
setStream
public void setStream(java.io.PrintStream stream)
Sets the output stream to a new value.- Parameters:
stream- the new output stream- Throws:
java.lang.NullPointerException- on nullstream- Since:
- 2.23.0
-
getStatusLevel
public Level getStatusLevel()
Returns the level for which the listener should receive events.- Specified by:
getStatusLevelin interfaceStatusListener- Returns:
- the log level
-
log
public void log(StatusData data)
Writes status messages to the console.- Specified by:
login interfaceStatusListener- Parameters:
data- a status data- Throws:
java.lang.NullPointerException- on nulldata
-
setFilters
@Deprecated public void setFilters(java.lang.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:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable
-
closeNonSystemStream
private static void closeNonSystemStream(java.io.OutputStream stream)
-
-