public class LoggingOutputStream extends OutputStream
OutputStream that forwards lines written to it to
a Logger at a specified level. Bytes are accumulated by this
OutputStream until a System.lineSeparator() value is found;
once the line ending is found, the line is flushed to the logger.
Bytes written to a LoggingOutputStream instance must have been
encoded using UTF-8. This affects proper
recognition of line separators and re-assembly of logged strings.
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_BUFFER_SIZE |
| Constructor and Description |
|---|
LoggingOutputStream(org.slf4j.Logger logger,
org.slf4j.event.Level level)
Creates a new
LoggingOutputStream writing to the provided logger and the
specified level. |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
flush() |
void |
write(int b) |
write, writepublic static final int DEFAULT_BUFFER_SIZE
public LoggingOutputStream(org.slf4j.Logger logger,
org.slf4j.event.Level level)
LoggingOutputStream writing to the provided logger and the
specified level.
Bytes written to this LoggingOutputStream must be UTF-8 encoded characters.
logger - the SLF4J Logger instance to which the stream should writelevel - the SLF4J level at which the stream is recorded to loggerpublic void write(int b)
throws IOException
write in class OutputStreamIOExceptionpublic void flush()
throws IOException
flush in interface Flushableflush in class OutputStreamIOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class OutputStreamIOExceptionCopyright © 2022. All rights reserved.