How to disable log4j logging from Java code
If you wanna achieve perfect silence (like for a quiet command line tool), you can always use the NullAppender.
Logger.getRootLogger().removeAllAppenders();
Logger.getRootLogger().addAppender(new NullAppender());
So, you have 3 loggers defined, including the root:
log4j.rootLogger=warn, stdout
log4j.logger.ac.biu.nlp.nlp.engineml=info, logfile
log4j.logger.org.BIU.utils.logging.ExperimentLogger=warn
Unfortunately, to disable them programatically, you need to specify ALL OF THEM in the code:
Logger.getLogger("ac.biu.nlp.nlp.engineml").setLevel(Level.OFF);
Logger.getLogger("org.BIU.utils.logging.ExperimentLogger").setLevel(Level.OFF);
Logger.getRootLogger().setLevel(Level.OFF);
Here's how to reset it back to what's set in the config file.