import org.apache.log4j.*;
public class LoggerDemo {
private static Logger logger = Logger.getLogger(LoggerDemo.class.getPackage().getName());
public LoggerDemo(String rbName) {
logger.setAdditivity(false);
logger.debug("A");
logger.setResourceBundle(java.util.ResourceBundle.getBundle(rbName));
logger.debug("B");
}
public void doLogging(String name) {
logger.debug("Entered the doLogging method..");
//do something
logger.info("printing the message...");
logger.debug("Exiting the doLogging method...");
}
public void doLocalizedLogging() {
logger.l7dlog(Level.DEBUG, "Entry", null);
logger.l7dlog(Level.DEBUG, "Exit", null);
}
public static void main(String args[]) {
String name = args[0];
String rbName = args[1];
LoggerDemo demo = new LoggerDemo(rbName);
demo.doLogging(name);
demo.doLocalizedLogging();
}
}
|