Class LoggingOutputStream

  • All Implemented Interfaces:
    Closeable, Flushable, AutoCloseable

    public class LoggingOutputStream
    extends ByteArrayOutputStream
    An OutputStream that writes contents to a Logger upon each call to flush(). Code from
    • Constructor Detail

      • LoggingOutputStream

        public LoggingOutputStream​(org.apache.log4j.Logger logger,
                                   org.apache.log4j.Level level)
        logger - Logger to write to
        level - Level at which to write the log message
    • Method Detail

      • flush

        public void flush()
                   throws IOException
        upon flush() write the existing contents of the OutputStream to the logger as a log record.
        Specified by:
        flush in interface Flushable
        flush in class OutputStream
        IOException - in case of error