Java by API/java.util.logging/MemoryHandler
Версия от 17:43, 31 мая 2010; (обсуждение)
new MemoryHandler(Handler target, int size, Level pushLevel)
import java.util.logging.ConsoleHandler;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import java.util.logging.MemoryHandler;
public class Main {
public static void main(String args[]) throws Exception {
Logger logger = Logger.getLogger("your.logging");
ConsoleHandler handler = new ConsoleHandler();
MemoryHandler mHandler = new MemoryHandler(handler, 10, Level.ALL);
logger.addHandler(mHandler);
logger.setUseParentHandlers(false);
LogRecord record1 = new LogRecord(Level.SEVERE, "This is SEVERE level message");
LogRecord record2 = new LogRecord(Level.WARNING, "This is WARNING level message");
logger.log(record1);
logger.log(record2);
}
}