In our product we use a number of external libraries. We do our logging with log4j, and most libraries do so as well, so we get most of the messages in our appenders fine.
But there are several libraries that just use System.out and System.err. So I am looking for a way to redirect System.out and System.err to our log4j appenders for a specific jar only, the other libraries that use log4j should not be affected, and those sometimes print to System.out and System.err too, and these messages should still go there.
Is this somehow possible?
Hypothesis – Never tried
Helpful sample code
http://blogs.oracle.com/nickstephen/entry/java_redirecting_system_out_and
and
log4j redirect stdout to DailyRollingFileAppender