List of usage examples for java.util.logging MemoryHandler MemoryHandler
public MemoryHandler(Handler target, int size, Level pushLevel)
From source file:Main.java
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);//from w w w .j av a 2 s .c o m 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); }
From source file:MailHandlerDemo.java
/** * Example for circular buffer behavior. The level, push level, and capacity * are set the same so that the memory handler push results in a mail * handler push. All messages are high priority. On close any remaining * records are discarded because they never reach the mail handler. <code> * ##logging.properties/* ww w . j av a 2s. c o m*/ * MailHandlerDemo.handlers=java.util.logging.MemoryHandler * java.util.logging.MemoryHandler.target=com.sun.mail.util.logging.MailHandler * com.sun.mail.util.logging.MailHandler.level=ALL * java.util.logging.MemoryHandler.level=ALL * java.util.logging.MemoryHandler.push=WARNING * com.sun.mail.util.logging.MailHandler.subject=Push only demo * com.sun.mail.util.logging.MailHandler.pushLevel=WARNING * ## * </code> */ private static void initPushOnly() { final int capacity = 3; final Level pushLevel = Level.WARNING; final MailHandler h = new MailHandler(capacity); h.setPushLevel(pushLevel); h.setSubject("Push only demo"); MemoryHandler m = new MemoryHandler(h, capacity, pushLevel); h.setLevel(m.getLevel()); LOGGER.addHandler(m); pushOnlyHandler = h; }
From source file:MailHandlerDemo.java
/** * Example for circular buffer behavior as normal priority. The push level, * and capacity are set the same so that the memory handler push results in * a mail handler push. All messages are normal priority. On close any * remaining records are discarded because they never reach the mail * handler. Use the LogManager config option or extend the MemoryHandler to * emulate this behavior via the logging.properties. *//*w w w . ja va 2 s.c o m*/ private static void initPushNormal() { final int capacity = 3; final MailHandler h = new MailHandler(capacity); h.setSubject("Push normal demo"); MemoryHandler m = new MemoryHandler(h, capacity, Level.WARNING) { @Override public void push() { super.push(); //push to target. super.flush(); //make the target send the email. } }; LOGGER.addHandler(m); pushNormalHandler = h; }