Setting log4j log level programmatically


private static void setupLog4j() {
System.out.println("setupLog4j");
BasicConfigurator.resetConfiguration();
// Start clean.
Logger.getRootLogger().removeAllAppenders();
// Create appender
ConsoleAppender console = new ConsoleAppender();
// Configure the appender
String PATTERN = "%d --[ %p ] %l: %m%n";
console.setLayout(new PatternLayout(PATTERN));
console.activateOptions();
console.setName("stdout");
Logger.getRootLogger().setLevel(Level.DEBUG);
BasicConfigurator.configure(console);
LOG = Logger.getLogger(MinerTest.class);
}

Leave a Reply

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


nine − 1 =