How to block writes to standard output in java (System.out.println())

499 Views Asked by At

In Java, how to block code from writing to system out?
My app calls a 3rd party library that spams logs by issuing numerous System.out.println() calls.
I don't have legal rights to decompile and patch the library.
I'm running Websphere 8.5.x

Considered using System.setOut(PrintStream out), but that will effect the entire process, while I only want to limit the effect to a single thread.

1

There are 1 best solutions below

0
On BEST ANSWER

If you can identify the thread you want to "mute" reliably somehow (e.g. by name), you can setOut to your own stream which will only delegate the calls to the actual System.out if they don't come from the muted thread.