Switching off Log4j logging using JAVA


Sometimes we need to switch off logging done by Log4j API. In most of the cases console logging is given by default for external APIs using Log4j.We can turn it off through simple Java code.Following is the explanation.

Import following packages :

import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;

Given below is the code to turn it off

try {

Logger log = Logger.getRootLogger();

}catch (Exception e)
System.out.println(“Error while turning off Log4j logger “+e.getMessage());

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *