public class LoggingOutputStream extends OutputStream
Example:
// Create PrintStream with autoFlush=true, otherwise
// LoggingOutputStream will accumulate bytes until closed.
System.setErr(new PrintStream(
new LoggingOutputStream(
Logger.getLogger("outLog"), Level.ERROR),
true));| Constructor and Description |
|---|
LoggingOutputStream(org.apache.log4j.Logger log,
org.apache.log4j.Level level)
Creates the Logging instance to flush to the given logger.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this output stream and releases any system resources
associated with this stream.
|
void |
flush()
Flushes this output stream and forces any buffered output
bytes to be written out.
|
protected String |
processLine(String s)
Examines an inout line and amends, if needed.
|
void |
write(int b)
Writes the specified byte to this output stream.
|
write, writepublic LoggingOutputStream(@Nonnull org.apache.log4j.Logger log, @Nonnull org.apache.log4j.Level level)
log - the Logger to write tolevel - the log levelNullPointerException - in case if one of arguments is null.public void write(int b)
throws IOException
write in class OutputStreamb - the byte to writeIOException - if an I/O error occurs.public void flush()
flush in interface Flushableflush in class OutputStreampublic void close()
close in interface Closeableclose in interface AutoCloseableclose in class OutputStreamprotected String processLine(String s)
s - an input line as was written to the streamCopyright © 2003–2022 Atlassian. All rights reserved.