} catch (Exception ex) { Logger.getLogger(LoggerFactory.class.getName()).log(Level.SEVERE, null, ex); result = new MemoryHandler();
class MyMemoryConsoleHandler { private Logger rootLogger; private MemoryHandler mh; private Logger l; private int size = 3; private int entries = 0; public MyMemoryConsoleHandler() { this.rootLogger = Logger.getLogger(""); this.rootLogger.removeHandler(rootLogger.getHandlers()[0]); ConsoleHandler ch = new ConsoleHandler(); this.l = Logger.getLogger("test"); this.mh = new MemoryHandler(ch,this.size,Level.OFF); } public synchronized void push() { this.mh.push(); if (this.entries > this.size) { this.l.severe("Entries in log discarded !!!"); this.mh.push(); } this.entries = 0; } public synchronized void addMessage(String m) { this.entries++; this.l.severe(m); } }
private Handler loadMemoryHandler(final JDKLoggerPluginConfiguration confirguration) throws Exception { final String message = "Must correctly configure target, size, and pushLevel for logging MemoryHandler."; if (confirguration.memoryHandlerTarget() == null || confirguration.memoryHandlerSize() == -1 || confirguration.memoryHandlerPushLevel() == null) { throw new IllegalArgumentException(message); } try { Class<?> targetClass = Class.forName(confirguration.memoryHandlerTarget()); return new MemoryHandler((Handler) targetClass.newInstance(), confirguration.memoryHandlerSize(), Level.parse(confirguration.memoryHandlerPushLevel())); } catch (Exception e) { throw new IllegalArgumentException(message, e); } }
private Handler loadMemoryHandler(final JDKLoggerPluginConfiguration confirguration) throws Exception { final String message = "Must correctly configure target, size, and pushLevel for logging MemoryHandler."; if (confirguration.memoryHandlerTarget() == null || confirguration.memoryHandlerSize() == -1 || confirguration.memoryHandlerPushLevel() == null) { throw new IllegalArgumentException(message); } try { Class<?> targetClass = Class.forName(confirguration.memoryHandlerTarget()); return new MemoryHandler((Handler) targetClass.newInstance(), confirguration.memoryHandlerSize(), Level.parse(confirguration.memoryHandlerPushLevel())); } catch (Exception e) { throw new IllegalArgumentException(message, e); } }
private void registerHandler(Session session,String uuid,String loggerName){ Handler handler = new MemoryHandler(new StompeeHandler(session,loggerName),1000,Level.FINEST); Logger logger = stompeeUtil.getLogger(loggerName); if(logger!=null){ logger.addHandler(handler); session.getUserProperties().put(HANDLER, handler); session.getUserProperties().put(ID, uuid); session.getUserProperties().put(LOGGER_NAME, loggerName); session.getUserProperties().put(LOG_LEVEL, stompeeUtil.getLevel(logger).getName()); } }
handler = mh; try { handler = new MemoryHandler(mh, mh.getCapacity(), mh.getPushLevel()); ses = newScheduledThreadPool(1, backgroundThreadFactory()); task = ses.scheduleAtFixedRate(this, 30L, 30L, TimeUnit.MINUTES);