Redirect System.out and System.err to slf4j

You can use sysout-over-slf4j.

The sysout-over-slf4j module allows a user to redirect all calls to System.out and System.err to an SLF4J defined logger with the name of the fully qualified class in which the System.out.println (or similar) call was made, at configurable levels.

If you are not using Maven, download the jar and add it to your classpath.

Alternatively, add it as a Maven dependency:

<dependency>
    <groupId>uk.org.lidalia</groupId>
    <artifactId>sysout-over-slf4j</artifactId>
    <version>1.0.2</version>
</dependency>

Then at application startup, call:

SysOutOverSLF4J.sendSystemOutAndErrToSLF4J();

Leave a Comment