/*
Logging In Java with the JDK 1.4 Logging API and Apache log4j
by Samudra Gupta
Apress Copyright 2003
ISBN:1590590996
*/
import org.apache.log4j.AsyncAppender;
import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.Logger;
public class AsyncLogging {
private static Logger logger = Logger.getLogger("name");
private AsyncAppender asyncAppender = null;
private ConsoleAppender consoleAppender = null;
/** Creates a new instance of AsyncLogging */
public AsyncLogging() {
try {
logger.setAdditivity(false);
asyncAppender = (AsyncAppender) logger.getRootLogger().getAppender(
"ASYNC");
asyncAppender.setBufferSize(4);
} catch (Exception e) {
System.out.println("error: " + e.toString());
}
}
/**
* This method simply logs the messages
*/
public void doLogging() {
logger.debug("Hello 1");
logger.debug("Hello 2");
logger.debug("Hello 3");
//logger.debug("Hello 4");
//logger.debug("Hello 5");
}
/**
* the main method
*/
public static void main(String args[]) {
AsyncLogging demo = new AsyncLogging();
demo.doLogging();
}
}
|