Skip to content

Instantly share code, notes, and snippets.

View nimaaj93's full-sized avatar
🎯
Focusing

Nima Ajdari nimaaj93

🎯
Focusing
View GitHub Profile
@nimaaj93
nimaaj93 / LoggingOutputStream.java
Created February 9, 2020 08:50 — forked from martijnvogten/LoggingOutputStream.java
Redirect System.out and System.err to an slf4j Logger
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import org.slf4j.Logger;
public class LoggingOutputStream extends OutputStream {
public static void redirectSysOutAndSysErr(Logger logger) {
System.setOut(new PrintStream(new LoggingOutputStream(logger, LogLevel.INFO)));