Package dk.netarkivet.common.utils
Class LoggingOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- dk.netarkivet.common.utils.LoggingOutputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
public class LoggingOutputStream extends java.io.OutputStream
OutputStream which can be used to redirect all stdout and stderr to a logger. Usage: System.setOut(new PrintStream(new LoggingOutputStream(LoggingOutputStream.LoggingLevel.INFO, log, "StdOut: "))); System.setErr(new PrintStream(new LoggingOutputStream(LoggingOutputStream.LoggingLevel.WARN, log, "StdErr: ")));
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LoggingOutputStream.LoggingLevel
Enum representing the standard logging levels for commons logging.
-
Constructor Summary
Constructors Constructor Description LoggingOutputStream(LoggingOutputStream.LoggingLevel loggingLevel, org.slf4j.Logger logger, java.lang.String prefix)
Constructor for the class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
write(int b)
-
-
-
Constructor Detail
-
LoggingOutputStream
public LoggingOutputStream(LoggingOutputStream.LoggingLevel loggingLevel, org.slf4j.Logger logger, java.lang.String prefix)
Constructor for the class.- Parameters:
loggingLevel
- The logging level at which to log messages from this instance.logger
- The logger to which messages will be logged.prefix
- A prefix by which output from this instance can be identified.
-
-
Method Detail
-
write
public void write(int b) throws java.io.IOException
- Specified by:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
-