Package org.apache.log4j

Examples of org.apache.log4j.Appender


    Enumeration<Logger> allLoggers = LogManager.getCurrentLoggers();
    while (allLoggers.hasMoreElements()) {
      Logger l = allLoggers.nextElement();
      Enumeration<Appender> allAppenders = l.getAllAppenders();
      while (allAppenders.hasMoreElements()) {
        Appender a = allAppenders.nextElement();
        if (a instanceof TaskLogAppender) {
          ((TaskLogAppender)a).flush();
        }
      }
    }
View Full Code Here


        Logger logger = LogManager.getLogger("org.apache.accumulo");
        if (null != logger) {
          // TODO ACCUMULO-2343 Create a specific appender for log-forwarding to the monitor
          // that can replace the AsyncAppender+SocketAppender.
          Appender appender = logger.getAppender("ASYNC");
          if (null != appender) {
            log.info("Closing log-forwarding appender");
            appender.close();
            log.info("Removing log-forwarding appender");
            logger.removeAppender(appender);
            loggingDisabled = true;
          }
        }
View Full Code Here

      return;
    }

    HashMap appenderBag =
      (HashMap) ec.getObjectMap().get(ActionConst.APPENDER_BAG);
    Appender appender = (Appender) appenderBag.get(appenderName);

    if (appender == null) {
      getLogger().warn("Could not find an appender named [" + appenderName + "]");
      inError = true;
      ec.addError(new ErrorItem("Could not find an appender named [" + appenderName + "]"));
View Full Code Here

      logger.debug("Popping layout from the object stack");
      ec.popObject();
     
      try {
        logger.debug("About to set the layout of the containing appender.");
        Appender appender = (Appender) ec.peekObject();
        appender.setLayout(layout);
      } catch(Exception ex) {
        logger.error("Could not set the layout for containing appender.", ex);
      }
    }
  }
View Full Code Here

    }
    public synchronized Handler[] getHandlers() {
        List<Handler> ret = new ArrayList<Handler>();
        Enumeration en = log.getAllAppenders();
        while (en.hasMoreElements()) {
            Appender ap = (Appender)en.nextElement();
            if (ap instanceof HandlerWrapper) {
                ret.add(((HandlerWrapper)ap).getHandler());
            }
        }
        return ret.toArray(new Handler[ret.size()]);
View Full Code Here

   *
   * @param repository
   */
  protected void attachListAppender(LoggerRepository repository) {
    Logger ll = repository.getLogger(Constants.LOG4J_PACKAGE_NAME);
    Appender appender = new ListAppender();
    appender.setName(Constants.TEMP_LIST_APPENDER_NAME);
    ll.addAppender(appender);
    ll.setAdditivity(false);
  }
View Full Code Here

  }


  void addAppender(String appenderClass, String appenderName) {
    cat.debug("addAppender called with "+appenderClass+", "+appenderName);
    Appender appender = (Appender)
       OptionConverter.instantiateByClassName(appenderClass,
                org.apache.log4j.Appender.class,
                null);
    appender.setName(appenderName);
    logger.addAppender(appender);

    //appenderMBeanRegistration();

  }
View Full Code Here

  }

  void appenderMBeanRegistration() {
    Enumeration enumeration = logger.getAllAppenders();
    while(enumeration.hasMoreElements()) {
      Appender appender = (Appender) enumeration.nextElement();
      registerAppenderMBean(appender);
    }
  }
View Full Code Here

  protected void append(LoggingEvent event) {

    // we assume appropriate syncronization has occured on this appender

    // determinge the key to lookup the Appender to use
    Appender appender = getSelector().select(event);
    appender.doAppend(event);

  }
View Full Code Here

  }

  private static void addAppenders(Logger logger, Set<Appender> allAppenders) {
      Enumeration appenders = logger.getAllAppenders();
      while (appenders.hasMoreElements()) {
          Appender appender = (Appender) appenders.nextElement();
          allAppenders.add(appender);
      }
  }
View Full Code Here

TOP

Related Classes of org.apache.log4j.Appender

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.