R
public class AsyncLoggingExample {
private static Logger logger = Logger.getRootLogger();
private AsyncAppender asyncAppender = null;
public AsyncLoggingExample() {
try {
logger.setAdditivity(false);
asyncAppender = (AsyncAppender) Logger.getRootLogger().getAppender("ASYNCAPP");
asyncAppender.setBufferSize(4);
}
catch (Exception e) {
System.out.println("error: " + e.toString());
}
}
public void doLogging() {
logger.info("AsyncLoggingExample 1");
logger.info("AsyncLoggingExample 2");
logger.info("AsyncLoggingExample 3");
logger.info("AsyncLoggingExample 4");
logger.info("AsyncLoggingExample 5");
}
public static void main(String args[]) {
System.out.println(Thread.currentThread().getName());
BasicConfigurator.configure();
AsyncLoggingExample AsyncLoggingExample = new AsyncLoggingExample();
AsyncLoggingExample.doLogging();
System.out.println(Thread.currentThread().getName());
}
}