Package org.apache.log4j.config

Examples of org.apache.log4j.config.PropertySetter


    // set the parameters of the nested component and/or configure the
    // nested compoments nested within
    NodeList children = nestedElement.getChildNodes();
    final int length = children.getLength();
    PropertySetter nestedBean = new PropertySetter(nestedComponent);

    for (int loop = 0; loop < length; loop++) {
      Node currentNode = children.item(loop);

      /* We're only interested in Elements */
 
View Full Code Here


        org.apache.log4j.spi.ErrorHandler.class, null);

    if (eh != null) {
      eh.setAppender(appender);

      PropertySetter propSetter = new PropertySetter(eh);
      NodeList children = element.getChildNodes();
      final int length = children.getLength();

      for (int loop = 0; loop < length; loop++) {
        Node currentNode = children.item(loop);
View Full Code Here

    Filter filter =
      (Filter) OptionConverter.instantiateByClassName(
        clazz, Filter.class, null);

    if (filter != null) {
      PropertySetter propSetter = new PropertySetter(filter);
      NodeList children = element.getChildNodes();
      final int length = children.getLength();

      for (int loop = 0; loop < length; loop++) {
        Node currentNode = children.item(loop);
View Full Code Here

  /**
     Used internally to parse the children of a category element.
  */
  protected void parseChildrenOfLoggerElement(
    Element catElement, Logger cat, boolean isRoot) {
    PropertySetter propSetter = new PropertySetter(cat);

    // Remove all existing appenders from cat. They will be
    // reconstructed if need be.
    cat.removeAllAppenders();

View Full Code Here

    String className = subst(pluginElement.getAttribute(CLASS_ATTR));
    LogLog.debug("Creating plugin: [" + className + ']');

    try {
      Plugin plugin = (Plugin) Loader.loadClass(className).newInstance();
      PropertySetter propSetter = new PropertySetter(plugin);

      plugin.setName(subst(pluginElement.getAttribute(NAME_ATTR)));

      NodeList children = pluginElement.getChildNodes();
      final int length = children.getLength();
View Full Code Here

    // remove both leading and trailing spaces
    value = value.trim();

    Object o = ec.peekObject();
    PropertySetter propSetter = new PropertySetter(o);
    value = ec.subst(OptionConverter.convertSpecialChars(value));

    // allow for variable substitution for name as well
    name = ec.subst(name);

    getLogger().debug(
      "In ParamAction setting parameter [{}] to value [{}].", name, value);
    propSetter.setProperty(name, value);
  }
View Full Code Here

    Pattern pattern, Attributes attributes, ExecutionContext ec) {
    //LogLog.debug("in NestComponentIA.isApplicable <" + pattern + ">");
    String nestedElementTagName = pattern.peekLast();

    Object o = ec.peekObject();
    PropertySetter parentBean = new PropertySetter(o);

    int containmentType = parentBean.canContainComponent(nestedElementTagName);

    switch (containmentType) {
    case PropertySetter.NOT_FOUND:
      return false;
View Full Code Here

    String className = subst(appenderElement.getAttribute(CLASS_ATTR));
    LogLog.debug("Class name: [" + className+']');   
    try {
      Object instance   = Class.forName(className).newInstance();
      Appender appender  = (Appender)instance;
      PropertySetter propSetter = new PropertySetter(appender);

      appender.setName(subst(appenderElement.getAttribute(NAME_ATTR)));
     
      NodeList children  = appenderElement.getChildNodes();
      final int length   = children.getLength();

      for (int loop = 0; loop < length; loop++) {
  Node currentNode = children.item(loop);

  /* We're only interested in Elements */
  if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
    Element currentElement = (Element)currentNode;

    // Parse appender parameters
    if (currentElement.getTagName().equals(PARAM_TAG)) {
            setParameter(currentElement, propSetter);
    }
    // Set appender layout
    else if (currentElement.getTagName().equals(LAYOUT_TAG)) {
      appender.setLayout(parseLayout(currentElement));
    }
    // Add filters
    else if (currentElement.getTagName().equals(FILTER_TAG)) {
      parseFilters(currentElement, appender);
    }
    else if (currentElement.getTagName().equals(ERROR_HANDLER_TAG)) {
      parseErrorHandler(currentElement, appender);
    }
    else if (currentElement.getTagName().equals(APPENDER_REF_TAG)) {
      String refName = subst(currentElement.getAttribute(REF_ATTR));
      if(appender instanceof AppenderAttachable) {
        AppenderAttachable aa = (AppenderAttachable) appender;
        LogLog.debug("Attaching appender named ["+ refName+
         "] to appender named ["+ appender.getName()+"].");
        aa.addAppender(findAppenderByReference(currentElement));
      } else {
        LogLog.error("Requesting attachment of appender named ["+
         refName+ "] to appender named ["+ appender.getName()+
                "] which does not implement org.apache.log4j.spi.AppenderAttachable.");
      }
    }
  }
      }
      propSetter.activate();
      return appender;
    }
    /* Yes, it's ugly.  But all of these exceptions point to the same
       problem: we can't create an Appender */
    catch (Exception oops) {
View Full Code Here

                null);
   
    if(eh != null) {
      eh.setAppender(appender);

      PropertySetter propSetter = new PropertySetter(eh);
      NodeList children = element.getChildNodes();
      final int length   = children.getLength();

      for (int loop = 0; loop < length; loop++) {
  Node currentNode = children.item(loop);
  if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
    Element currentElement = (Element) currentNode;
    String tagName = currentElement.getTagName();
    if(tagName.equals(PARAM_TAG)) {
            setParameter(currentElement, propSetter);
    } else if(tagName.equals(APPENDER_REF_TAG)) {
      eh.setBackupAppender(findAppenderByReference(currentElement));
    } else if(tagName.equals(LOGGER_REF)) {
      String loggerName = currentElement.getAttribute(REF_ATTR);     
      Logger logger = repository.getLogger(loggerName);
      eh.setLogger(logger);
    } else if(tagName.equals(ROOT_REF)) {
      Logger root = repository.getRootLogger();
      eh.setLogger(root);
    }
  }
      }
      propSetter.activate();
      appender.setErrorHandler(eh);
    }
  }
View Full Code Here

    String clazz = subst(element.getAttribute(CLASS_ATTR));
    Filter filter = (Filter) OptionConverter.instantiateByClassName(clazz,
                                                Filter.class, null);
   
    if(filter != null) {
      PropertySetter propSetter = new PropertySetter(filter);
      NodeList children = element.getChildNodes();
      final int length   = children.getLength();

      for (int loop = 0; loop < length; loop++) {
  Node currentNode = children.item(loop);
  if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
    Element currentElement = (Element) currentNode;
    String tagName = currentElement.getTagName();
    if(tagName.equals(PARAM_TAG)) {
            setParameter(currentElement, propSetter);
    }
  }
      }
      propSetter.activate();
      LogLog.debug("Adding filter of type ["+filter.getClass()
       +"] to appender named ["+appender.getName()+"].");
      appender.addFilter(filter);
    }   
  }
View Full Code Here

TOP

Related Classes of org.apache.log4j.config.PropertySetter

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.