Reputation: 1333
Application I'm currently developing runs some independent library code which outputs loads of logs to the stdout via PrintWriter. Additionally, tasks handled by the library are run in the seperate threads. I'd like to find out if it's possible to ignore (prevent logs from appearing on the console) those logs. However, I can't directly modify the library code, so simple solution is out of question.
Cheers!
Upvotes: 0
Views: 138
Reputation: 340733
Which lilbrary is it? Or to be precise: is it using some logging framework? If it just prints stuff to console using System.out
that it is basically a Poorly Written Library (tm). In that case everything you can do is to redirect System.out
to slft4j using System Out and Err redirected to SLF4J. Basically it override default console using System.setErr()
and System.setOut()
.
If your library uses any logging framework (probably java.util.logging
) try to figure out which loggers/categories does it use and filter them out in your logging framework.
Note that I am not mentioning anything about threads. Filtering logs/console output based on current thread is a bit tricky, use loggers hierarchy instead in your logging framework of choice.
Upvotes: 1