I use a legacy library that writes logs using log4j. My default log4j.properties file directs the log to the console, but in some specific functions of my main program, I would
You can use
Logger.getRootLogger().setLevel(Level.OFF);
to disable any logging in java code