Package org.apache.log4j

Examples of org.apache.log4j.Category$PrivateManager


  void main(String argv[]) {

    // A1 and A2 should be added to root by reading the config file
    PropertyConfigurator.configure(argv[0]);

    Category root = Category.getRoot();

    Enumeration e1 = root.getAllAppenders();
    Vector v = new Vector(1);
   
    while(e1.hasMoreElements()) {
      Appender a = (Appender) e1.nextElement();
      v.addElement(a);
      String appenderName = a.getName()
      if(a != root.getAppender(appenderName)) {
  System.out.println(appenderName + " lookup failed. Exiting.");
  System.exit(1);
      }
      // attempt to add the existing appender
      root.addAppender(a);
    }

    // attempt to add a null appender
    root.addAppender(null);

    Enumeration e2 = root.getAllAppenders();

    for(int i = 0; i < v.size(); i++) {
      if(v.elementAt(i) != e2.nextElement()) {
      }
    }
View Full Code Here


  // System.err.flush();
  //}

  public void run() {
    LoggingEvent event;
    Category remoteCategory;

    try {
      while(true) { 
  event = (LoggingEvent) ois.readObject()
  remoteCategory = hierarchy.getInstance(event.categoryName);
  if(event.priority.isGreaterOrEqual(remoteCategory.getChainedPriority())) {
    remoteCategory.callAppenders(event)
  }
      }
    }
    catch(java.io.EOFException e) {
      cat.info("Caught java.io.EOFException closing conneciton.");
View Full Code Here

  }

  static
  void sample() {
    int i = -1;
    Category root = Category.getRoot();   
    cat.debug("Message " + ++i);
    cat.warn ("Message " + ++i);
    cat.error("Message " + ++i);       
    Exception e = new Exception("Just testing");
    cat.debug("Message " + ++i, e);
View Full Code Here

  static
  void sample() {
    int i = -1;
    XCategory cat = (XCategory) XCategory.getInstance("some.cat");   

    Category root = Category.getRoot();   
    cat.trace("Message " + ++i);
    cat.debug("Message " + ++i);
    cat.warn ("Message " + ++i);
    cat.error("Message " + ++i);       
    cat.fatal("Message " + ++i);       
View Full Code Here

      TopicSubscriber topicSubscriber =
           topicSession.createDurableSubscriber(topic, "x");

     
      LoggingEvent event;
      Category remoteCategory;   

      while(true) {
  ObjectMessage msg = (ObjectMessage)topicSubscriber.receive();     
  event = (LoggingEvent) msg.getObject();
  remoteCategory = Category.getInstance(event.categoryName);
  remoteCategory.callAppenders(event)
 
  // dump the JMSMessage
  // remoteCategory.debug(msg);

      }
View Full Code Here

  }

  static
  void test() {
    int i = -1;
    Category root = Category.getRoot();
   
    cat.trace("Message " + ++i);
    cat.debug("Message " + ++i);
    root.debug("Message " + i);
    cat.info ("Message " + ++i);
    cat.warn ("Message " + ++i);
    cat.error("Message " + ++i);   
    cat.log(Priority.FATAL, "Message " + ++i);   
    Exception e = new Exception("Just testing");
View Full Code Here

  }

  static
  void test() {
    int i = -1;
    Category root = Category.getRoot();
   
    cat.debug("Message " + ++i);
    root.debug("Message " + i);       

    cat.info ("Message " + ++i);
    root.info("Message " + i);       

    cat.warn ("Message " + ++i);
    root.warn("Message " + i);       

    cat.error("Message " + ++i);
    root.error("Message " + i);
   
    cat.log(Priority.FATAL, "Message " + ++i);
    root.log(Priority.FATAL, "Message " + i);   
   
    Exception e = new Exception("Just testing");
    cat.debug("Message " + ++i, e);
    root.debug("Message " + i, e);
   
    cat.error("Message " + ++i, e);
    root.error("Message " + i, e);   
  }
View Full Code Here

    System.exit(1);
  }

  static
  void init(String host, String portStr) {
    Category root = Category.getRoot();
    BasicConfigurator.configure();
    try {
      int port   = Integer.parseInt(portStr);
      cat.info("Creating socket appender ("+host+","+port+").");
      s = new SocketAppender(host, port);
      s.setName("S");
      root.addAppender(s);
    }
    catch(java.lang.NumberFormatException e) {
      e.printStackTrace();
      usage("Could not interpret port number ["+ portStr +"].");
    }
View Full Code Here

    }
  }

  static
  void loop() {
    Category root = Category.getRoot();
    InputStreamReader in = new InputStreamReader(System.in);
    System.out.println("Type 'q' to quit");
    int i;
    int k = 0;
    while (true) {
      cat.debug("Message " + k++);
      cat.info("Message " + k++);
      cat.warn("Message " + k++);
      cat.error("Message " + k++, new Exception("Just testing"));
      try {i = in.read(); }
      catch(Exception e) { return; }
      if(i == -1) break;
      if(i == 'q') break;
      if(i == 'r') {
  System.out.println("Removing appender S");
  root.removeAppender("S");
      }
    }
  }
View Full Code Here

  static
  void test() {
    int i = -1;
   
    NDC.push("NDC");
    Category root = Category.getRoot();

    cat.debug("Message " + ++i);
    root.debug("Message " + i);       

    cat.info ("Message " + ++i);
    root.info("Message " + i);       

    cat.warn ("Message " + ++i);
    root.warn("Message " + i);       

    cat.error("Message " + ++i);
    root.error("Message " + i);
   
    cat.log(Priority.FATAL, "Message " + ++i);
    root.log(Priority.FATAL, "Message " + i);   
   
    Exception e = new Exception("Just testing");
    cat.debug("Message " + ++i, e);
    root.debug("Message " + i, e);
   
    cat.info("Message " + ++i, e);
    root.info("Message " + i, e);   

    cat.warn("Message " + ++i , e);
    root.warn("Message " + i , e);   

    cat.error("Message " + ++i, e);
    root.error("Message " + i, e);   

    cat.log(Priority.FATAL, "Message " + ++i, e);
    root.log(Priority.FATAL, "Message " + i, e);   


    // It is always a good idea to call this method when exiting an
    // application.
    Category.shutdown();   
View Full Code Here

TOP

Related Classes of org.apache.log4j.Category$PrivateManager

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.