简体   繁体   English

如何在Java(System.out.println())中阻止对标准输出的写入

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

In Java, how to block code from writing to system out? 在Java中,如何阻止代码写入系统?
My app calls a 3rd party library that spams logs by issuing numerous System.out.println() calls. 我的应用通过发出大量System.out.println()调用来调用垃圾日志的第三方库。
I don't have legal rights to decompile and patch the library. 我没有反编译和修补库的合法权利。
I'm running Websphere 8.5.x 我正在运行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. 考虑使用System.setOut(PrintStream out) ,但这将影响整个过程,而我只想将效果限制为单个线程。

如果您可以确定要可靠地“静音”的线程(例如,按名称),则可以将setOut为自己的流,如果它们不是来自静音线程,则仅将调用委派给实际的System.out

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM