Package org.apache.log4j.spi

Examples of org.apache.log4j.spi.ErrorItem


    if (Option.isEmpty(conversionWord)) {
      inError = true;
      errorMsg = "No 'conversionWord' attribute in <conversionRule>";
      getLogger().warn(errorMsg);
      ec.addError(new ErrorItem(errorMsg));

      return;
    }

    if (Option.isEmpty(converterClass)) {
      inError = true;
      errorMsg = "No 'converterClass' attribute in <conversionRule>";
      getLogger().warn(errorMsg);
      ec.addError(new ErrorItem(errorMsg));

      return;
    }

    try {
      getLogger().debug(
        "About to add conversion rule [{}, {}] to layout", conversionWord, converterClass);

      LoggerRepository repository = (LoggerRepository) ec.getObjectStack().get(0);

      //
      //   cast may fail with user supplied repository
      Map ruleRegistry = (Map) ((LoggerRepositoryEx) repository).getObject(PatternLayout.PATTERN_RULE_REGISTRY);
      if(ruleRegistry == null) {
        ruleRegistry = new HashMap();
        ((LoggerRepositoryEx) repository).putObject(PatternLayout.PATTERN_RULE_REGISTRY, ruleRegistry);
      }
      // put the new rule into the rule registry
      ruleRegistry.put(conversionWord, converterClass);
 
    } catch (Exception oops) {
      inError = true;
      errorMsg = "Could not add conversion rule to PatternLayout.";
      getLogger().error(errorMsg, oops);
      ec.addError(new ErrorItem(errorMsg));
    }
  }
View Full Code Here


  public void begin(ExecutionContext ec, String name, Attributes attributes) {
    String valueStr = attributes.getValue(VALUE_ATR);

    if (Option.isEmpty(valueStr)) {
      ec.addError(
        new ErrorItem("The literal action requires a value attribute"));
      return;
    }

    try {
      Integer i = Integer.valueOf(valueStr);
      ec.pushObject(i);
    } catch (NumberFormatException nfe) {
      ec.addError(
        new ErrorItem(
          "The value [" + valueStr + "] could not be converted to an Integer",
          nfe));
      throw nfe;
    }
  }
View Full Code Here

        result = ((Integer) o1).intValue();
      } else {
        String errMsg =
          "Object [" + o1
          + "] currently at the top of the stack is not an integer.";
        ec.addError(new ErrorItem(errMsg));
        throw new IllegalArgumentException(errMsg);
      }
    } catch (EmptyStackException ese) {
      ec.addError(
        new ErrorItem("Expecting an integer on the execution stack."));
      throw ese;
    }
    return result;
  }
View Full Code Here

        result = ((Integer) o1).intValue();
      } else {
        String errMsg =
          "Object [" + o1
          + "] currently at the top of the stack is not an integer.";
        ec.addError(new ErrorItem(errMsg));
        throw new IllegalArgumentException(errMsg);
      }
    } catch (EmptyStackException ese) {
      ec.addError(
        new ErrorItem("Expecting an integer on the execution stack."));
      throw ese;
    }
    return result;
  }
View Full Code Here

   
    ListAppender listAppender = (ListAppender) ll.getAppender(Constants.TEMP_LIST_APPENDER_NAME);
    if(listAppender == null) {
      String errMsg = "Could not find appender "+Constants.TEMP_LIST_APPENDER_NAME;
      getLogger(repository).error(errMsg);
      addError(new ErrorItem(errMsg));
      return;
    }
   
    List eventList = listAppender.getList();
    int size = eventList.size();
View Full Code Here

    ConsoleAppender consoleAppender =
      (ConsoleAppender) ll.getAppender(Constants.TEMP_CONSOLE_APPENDER_NAME);
    if (consoleAppender == null) {
      String errMsg =
        "Could not find appender " + Constants.TEMP_LIST_APPENDER_NAME;
      errorList.add(new ErrorItem(errMsg));
      return;
    }
    consoleAppender.close();
    ll.removeAppender(consoleAppender);
  }
View Full Code Here

   * Dump any errors on System.out.
   */
  public void dumpErrors() {
    List errorList = getErrorList();
    for(int i = 0; i < errorList.size(); i++) {
      ErrorItem ei = (ErrorItem) errorList.get(i);
      ei.dump(System.out);
    }
  }
View Full Code Here

      props.load(istream);
      istream.close();
    } catch (IOException e) {
      String errMsg =
        "Could not read configuration file [" + configFileName + "].";
      addError(new ErrorItem(errMsg, e));
      getLogger(repo).error(errMsg, e);
      return;
    }

    // If we reach here, then the config file is alright.
View Full Code Here

      props.load(in);
      in.close();
    } catch (java.io.IOException e) {
      String errMsg =
        "Could not read configuration file from URL [" + configURL + "].";
      addError(new ErrorItem(errMsg, e));
      getLogger(repository).error(errMsg, e);
      return;
    }

    doConfigure(props, repository);
View Full Code Here

    try {
      props.load(configStream);
    } catch (java.io.IOException e) {
      String errMsg =
        "Could not read configuration file from input stream.";
      addError(new ErrorItem(errMsg, e));
      getLogger(repository).error(errMsg, e);
      return;
    }

    doConfigure(props, repository);
View Full Code Here

TOP

Related Classes of org.apache.log4j.spi.ErrorItem

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.