Adapted from http://www.mail-archive.com/user@slf4j.org/msg00674.html for slf4j.
An OutputStream that flushes out to a Category.
Note that no data is written out to the Category until the stream is
flushed or closed.
Example:
// make sure everything sent to System.err is logged
System.setErr(new PrintStream(new
LoggingOutputStream(Logger.getRootCategory(),
Level.WARN), true));
// make sure everything sent to System.out is also logged
System.setOut(new PrintStream(new
LoggingOutputStream(Logger.getRootCategory(),
Level.INFO), true));