I am using a library that prints a bunch of superfluous information to the console when I reference it. Is there a way to silence the output of the library?
Using the printf() and print() methods The PrintStream class of Java provides two more methods to print data on the console (in addition to the println() method). The print() − This method accepts a single value of any of the primitive or reference data types as a parameter and prints the given value on the console.
print(): print() method in Java is used to display a text on the console. This text is passed as the parameter to this method in the form of String. This method prints the text on the console and the cursor remains at the end of the text at the console. The next printing takes place from just here.
The print() method is used to print text on the console. It is an overloaded method of the PrintStream class. It accepts a string as a parameter. After printing the statement, the cursor remains on the same line.
If it is using a logging framework (log4j, commons-logging, etc), you can edit/create a properties file to indicate a high logging treshold. in log4j this would look like:
log4j.logger.org.library=error
If the library is using System.out
, that's not a good library in the first place. You can change the PrintStream
by calling System.setOut(yourDummyPrintStream)
(and System.setErr(..)
). Your dummy print stream would just swallow the data and not print it anywhere.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With