I am using Apache Common Logging library in my standalone application. After searching through the web, I try to turn off the logging by using
package javaap
The problem with your example is that the Log class is instantiated before the property is set. If you create the Log instance after the property is set the example works properly. For example if you move it into the main method:
package javaapplication1;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
*
* @author yccheok
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
System.setProperty("org.apache.commons.logging.Log",
"org.apache.commons.logging.impl.NoOpLog");
Log log = LogFactory.getLog(Main.class);
log.info("You do not want to see me");
}
}