Package org.objectweb.util.monolog.api

Examples of org.objectweb.util.monolog.api.Handler


        }
    }

    public void removeHandlerFromLogger(String handlerName, String loggerName)
            throws RemoteException {
        Handler h = mf.getHandler(handlerName);
        if (h == null) {
            return;
        }
        TopicalLogger l = (TopicalLogger) mf.getLogger(loggerName);
        try {
View Full Code Here


        }
        return hns;
    }

    public Map getHandlerAttributes(String handlername)  {
        Handler h = mf.getHandler(handlername);
        String[] ans = h.getAttributeNames();
        Map m = new HashMap(ans.length);
        for(int i=0; i<ans.length; i++) {
            m.put(ans[i], h.getAttribute(ans[i]));
        }
        m.put("name", handlername);
        return m;
    }
View Full Code Here

        return m;
    }

    public void setHandlerAttribute(String handlername, String attributeName,
            String value)  {
        Handler h = mf.getHandler(handlername);
        if (h == null) {
            return;
        }
        h.setAttribute(attributeName, value);
    }
View Full Code Here

        return lis;
    }

    public void addHandlerToLogger(String handlername, String loggerName)
             {
        Handler h = mf.getHandler(handlername);
        if (h == null) {
            return;
        }
        TopicalLogger l = (TopicalLogger) mf.getLogger(loggerName);
        try {
View Full Code Here

        }
    }

    public void removeHandlerFromLogger(String handlerName, String loggerName)
             {
        Handler h = mf.getHandler(handlerName);
        if (h == null) {
            return;
        }
        TopicalLogger l = (TopicalLogger) mf.getLogger(loggerName);
        try {
View Full Code Here

  public JMX(LoggerFactory lf) {
    logger = lf.getLogger("monolog.examples.jmx");
  }

  private void activateNodification() {
    Handler handler = Monolog.getMonologFactory().getHandler("jmxHandler");
    if (handler == null || !(handler instanceof NotificationEmitter)) {
      logger.log(BasicLevel.WARN, "No JMX handler in the configuration");
    } else {
      ((NotificationEmitter) handler).addNotificationListener(this, null, null);
    }
View Full Code Here

    } else {
      ((NotificationEmitter) handler).addNotificationListener(this, null, null);
    }
  }
  private void desactivateNodification() {
    Handler handler = Monolog.getMonologFactory().getHandler("jmxHandler");
    if (handler == null || !(handler instanceof NotificationEmitter)) {
      logger.log(BasicLevel.WARN, "No JMX handler in the configuration");
    } else {
      try {
        logger.log(BasicLevel.DEBUG, "remove notification");
View Full Code Here

        for (Enumeration en = prop.keys(); en.hasMoreElements();) {
            String key = (String) en.nextElement();
            if (key.startsWith(HANDLER_FIELD + DOT)) {
                String handlerName = DottedStringTools.getBegin(
                        DottedStringTools.getEnd(key));
                Handler h = mf.getHandler(handlerName);
                if (h != null && !hs.contains(h)) {
                    //Activate only used handler
                    hs.addElement(h);
                } // do not activate unsued handler
                parseHandlerProp(prop, key, mf);
View Full Code Here

            logger = (TopicalLogger)
          mf.getLogger(DottedStringTools.getBegin(temp));
            cleanOldHandler(logger);
            while(st.hasMoreTokens()) {
                String hn = st.nextToken();
                Handler h = mf.getHandler(hn);
                if (h == null) {
                    h = parseHandlerProp(prop, HANDLER_FIELD + DOT + value
                            + DOT + HANDLER_TYPE_ATTRIBUTE, mf);
                }
                if (debug) {
                    debug("add handler " + h.getName() + " to the logger " + logger.getName());
                }
                logger.addHandler(h);
            }
        } else if (TOPIC_FIELD.equalsIgnoreCase(last)) {
            logger = (TopicalLogger)
              mf.getLogger(DottedStringTools.getBegin(temp));
            String value = prop.getProperty(key).trim();
            StringTokenizer st = new StringTokenizer(value, ", ;:", false);
            cleanOldHandler(logger);
            while(st.hasMoreTokens()) {
                String topic = st.nextToken();
                if (debug) {
                    debug("add topic " + topic + " to the logger " + logger.getName());
                }
                logger.addTopic(topic);
            }
        } else { //old declaration
            temp = DottedStringTools.getBegin(temp); // remove the number
            last = DottedStringTools.getLast(temp); // attribute name
            temp = DottedStringTools.getBegin(temp); // logger name
            logger = (TopicalLogger) mf.getLogger(temp);
            if (last.equalsIgnoreCase(HANDLER_FIELD)) {
                // Assign an handler to a logger
                String value = prop.getProperty(key).trim();
                Handler h = mf.getHandler(value);
                if (h == null) {
                    h = parseHandlerProp(prop, HANDLER_FIELD + DOT + value
                            + DOT + HANDLER_TYPE_ATTRIBUTE, mf);
                }
                cleanOldHandler(logger);
                if (debug) {
                    debug("add handler " + h.getName() + " to the logger " + logger.getName());
                }
                logger.addHandler(h);
            } else if (last.equalsIgnoreCase(TOPIC_FIELD)) {
                // Assign a topic to a logger
                String topic = prop.getProperty(key).trim();
View Full Code Here

                    "This key is not a Handler field:" + key);
        }
        temp = DottedStringTools.getEnd(key);
        String attribute = DottedStringTools.getLast(temp);
        String handlerName = DottedStringTools.getBegin(temp);
        Handler hc = hf.getHandler(handlerName);
        if (hc == null) {
            String stringType = prop.getProperty(HANDLER_FIELD + DOT + handlerName
                    + DOT + HANDLER_TYPE_ATTRIBUTE, null);
            if (stringType == null) {
                throw new Exception("Impossible to define the handler "
                        + temp + ": the type is not defined");
            }
            hc = hf.createHandler(handlerName, stringType);
            if (hc == null) {
                throw new Exception(
                        "The HandlerFactory does not create the Handler: name="
                        + handlerName + " / type=" + stringType);
            }
        }
        if (hc != null && !HANDLER_TYPE_ATTRIBUTE.equalsIgnoreCase(attribute)) {
            String v = prop.getProperty(key).trim();
            if (debug) {
                debug("assign property (" + attribute + ", " + v
                        + ") to the handler '" + handlerName);
            }
            hc.setAttribute(attribute, v);
        }
      return hc;
    }
View Full Code Here

TOP

Related Classes of org.objectweb.util.monolog.api.Handler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.