logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject cvs commit: logging-log4j/examples/src/trivial Trivial.java
Date Mon, 06 Sep 2004 14:03:48 GMT
ceki        2004/09/06 07:03:48

  Modified:    src/java/org/apache/log4j/nt/test NTMin.java
               examples/src/factor NumberCruncherServer.java
               src/java/org/apache/log4j/net/test SyslogMin.java
                        SocketMin.java
               src/java/org/apache/log4j/net SimpleSocketServer.java
               examples/src/trivial Trivial.java
  Log:
  Cateory -> Logger
  Category.getInstance -> Logger.getLogger
  
  Revision  Changes    Path
  1.6       +8 -8      logging-log4j/src/java/org/apache/log4j/nt/test/NTMin.java
  
  Index: NTMin.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/nt/test/NTMin.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- NTMin.java	9 May 2004 18:37:56 -0000	1.5
  +++ NTMin.java	6 Sep 2004 14:03:48 -0000	1.6
  @@ -8,7 +8,7 @@
   package org.apache.log4j.nt.test;
   
   
  -import org.apache.log4j.Category;
  +import org.apache.log4j.Logger;
   import org.apache.log4j.BasicConfigurator;
   import org.apache.log4j.nt.NTEventLogAppender;
   import org.apache.log4j.Level;
  @@ -17,7 +17,7 @@
   
   public class NTMin {
   
  -  static Category cat = Category.getInstance(NTMin.class.getName());
  +  static Logger logger = Logger.getLogger(NTMin.class.getName());
   
     public
     static
  @@ -51,11 +51,11 @@
     void test(String host) {
       NDC.push(host);
       int i  = 0;
  -    cat.debug( "Message " + i++);
  -    cat.info( "Message " + i++);
  -    cat.warn( "Message " + i++);
  -    cat.error( "Message " + i++);
  -    cat.log(Level.FATAL, "Message " + i++);
  -    cat.debug("Message " + i++,  new Exception("Just testing."));
  +    logger.debug( "Message " + i++);
  +    logger.info( "Message " + i++);
  +    logger.warn( "Message " + i++);
  +    logger.error( "Message " + i++);
  +    logger.log(Level.FATAL, "Message " + i++);
  +    logger.debug("Message " + i++,  new Exception("Just testing."));
     }
   }
  
  
  
  1.3       +8 -9      logging-log4j/examples/src/factor/NumberCruncherServer.java
  
  Index: NumberCruncherServer.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/examples/src/factor/NumberCruncherServer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- NumberCruncherServer.java	20 Apr 2004 09:51:24 -0000	1.2
  +++ NumberCruncherServer.java	6 Sep 2004 14:03:48 -0000	1.3
  @@ -16,7 +16,7 @@
   
   package factor;
   
  -import org.apache.log4j.Category;
  +import org.apache.log4j.Logger;
   import org.apache.log4j.NDC;
   import org.apache.log4j.PropertyConfigurator;
   
  @@ -61,8 +61,7 @@
    */
   public class NumberCruncherServer extends UnicastRemoteObject
     implements NumberCruncher {
  -  static Category cat =
  -    Category.getInstance(NumberCruncherServer.class.getName());
  +  final static Logger logger = Logger.getLogger(NumberCruncherServer.class);
   
     public NumberCruncherServer() throws RemoteException {
     }
  @@ -82,7 +81,7 @@
       // contained in cookies.
       NDC.push(String.valueOf(number));
   
  -    cat.info("Beginning to factor.");
  +    logger.info("Beginning to factor.");
   
       if (number <= 0) {
         throw new IllegalArgumentException(
  @@ -98,10 +97,10 @@
         // It is bad practice to place log requests within tight loops.
         // It is done here to show interleaved log output from
         // different requests. 
  -      cat.debug("Trying to see if " + i + " is a factor.");
  +      logger.debug("Trying to see if " + i + " is a factor.");
   
         if ((n % i) == 0) {
  -        cat.info("Found factor " + i);
  +        logger.info("Found factor " + i);
           factors.addElement(new Integer(i));
   
           do {
  @@ -115,7 +114,7 @@
       }
   
       if (n != 1) {
  -      cat.info("Found factor " + n);
  +      logger.info("Found factor " + n);
         factors.addElement(new Integer(n));
       }
   
  @@ -163,9 +162,9 @@
       try {
         ncs = new NumberCruncherServer();
         Naming.rebind("Factor", ncs);
  -      cat.info("NumberCruncherServer bound and ready to serve.");
  +      logger.info("NumberCruncherServer bound and ready to serve.");
       } catch (Exception e) {
  -      cat.error("Could not bind NumberCruncherServer.", e);
  +      logger.error("Could not bind NumberCruncherServer.", e);
         return;
       }
       NumberCruncherClient.loop(ncs);
  
  
  
  1.6       +8 -8      logging-log4j/src/java/org/apache/log4j/net/test/SyslogMin.java
  
  Index: SyslogMin.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/net/test/SyslogMin.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SyslogMin.java	9 May 2004 18:37:57 -0000	1.5
  +++ SyslogMin.java	6 Sep 2004 14:03:48 -0000	1.6
  @@ -8,7 +8,7 @@
   
   package org.apache.log4j.net.test;
   
  -import org.apache.log4j.Category;
  +import org.apache.log4j.Logger;
   import org.apache.log4j.Level;
   import org.apache.log4j.PropertyConfigurator;
   import org.apache.log4j.NDC;
  @@ -16,7 +16,7 @@
   
   public class SyslogMin {
   
  -  static Category CAT = Category.getInstance(SyslogMin.class.getName());
  +  final static Logger LOG = Logger.getLogger(SyslogMin.class.getName());
   
     public
     static
  @@ -50,11 +50,11 @@
     void test(String host) {
       NDC.push(host);
       int i  = 0;
  -    CAT.debug( "Message " + i++);
  -    CAT.info( "Message " + i++);
  -    CAT.warn( "Message " + i++);
  -    CAT.error( "Message " + i++);
  -    CAT.log(Level.FATAL, "Message " + i++);
  -    CAT.debug("Message " + i++,  new Exception("Just testing."));
  +    LOG.debug( "Message " + i++);
  +    LOG.info( "Message " + i++);
  +    LOG.warn( "Message " + i++);
  +    LOG.error( "Message " + i++);
  +    LOG.log(Level.FATAL, "Message " + i++);
  +    LOG.debug("Message " + i++,  new Exception("Just testing."));
     }
   }
  
  
  
  1.7       +13 -14    logging-log4j/src/java/org/apache/log4j/net/test/SocketMin.java
  
  Index: SocketMin.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/net/test/SocketMin.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SocketMin.java	19 May 2004 14:36:22 -0000	1.6
  +++ SocketMin.java	6 Sep 2004 14:03:48 -0000	1.7
  @@ -7,17 +7,16 @@
   
   package org.apache.log4j.net.test;
   
  -import org.apache.log4j.Category;
  +import org.apache.log4j.Logger;
   import org.apache.log4j.BasicConfigurator;
   import org.apache.log4j.Level;
  -import org.apache.log4j.Logger;
   import org.apache.log4j.net.SocketAppender;
   import org.apache.log4j.NDC;
   import java.io.InputStreamReader;
   
   public class SocketMin {
   
  -  static Category cat = Category.getInstance(SyslogMin.class.getName());
  +  static Logger logger = Logger.getLogger(SyslogMin.class);
     static SocketAppender s;
   
     public
  @@ -51,7 +50,7 @@
       BasicConfigurator.configure();
       try {
         int port   = Integer.parseInt(portStr);
  -      cat.info("Creating socket appender ("+host+","+port+").");
  +      logger.info("Creating socket appender ("+host+","+port+").");
         s = new SocketAppender(host, port);
         s.setName("S");
         root.addAppender(s);
  @@ -75,10 +74,10 @@
       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"));
  +      logger.debug("Message " + k++);
  +      logger.info("Message " + k++);
  +      logger.warn("Message " + k++);
  +      logger.error("Message " + k++, new Exception("Just testing"));
         try {i = in.read(); }
         catch(Exception e) { return; }
         if(i == -1) break;
  @@ -93,11 +92,11 @@
     static
     void test() {
       int i  = 0;
  -    cat.debug( "Message " + i++);
  -    cat.info( "Message " + i++);
  -    cat.warn( "Message " + i++);
  -    cat.error( "Message " + i++);
  -    cat.log(Level.FATAL, "Message " + i++);
  -    cat.debug("Message " + i++,  new Exception("Just testing."));
  +    logger.debug( "Message " + i++);
  +    logger.info( "Message " + i++);
  +    logger.warn( "Message " + i++);
  +    logger.error( "Message " + i++);
  +    logger.log(Level.FATAL, "Message " + i++);
  +    logger.debug("Message " + i++,  new Exception("Just testing."));
     }
   }
  
  
  
  1.9       +6 -7      logging-log4j/src/java/org/apache/log4j/net/SimpleSocketServer.java
  
  Index: SimpleSocketServer.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/net/SimpleSocketServer.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SimpleSocketServer.java	28 May 2004 14:51:13 -0000	1.8
  +++ SimpleSocketServer.java	6 Sep 2004 14:03:48 -0000	1.9
  @@ -16,7 +16,7 @@
   
   package org.apache.log4j.net;
   
  -import org.apache.log4j.Category;
  +import org.apache.log4j.Logger;
   import org.apache.log4j.LogManager;
   import org.apache.log4j.PropertyConfigurator;
   import org.apache.log4j.joran.JoranConfigurator;
  @@ -41,8 +41,7 @@
     *  @since 0.8.4
     * */
   public class SimpleSocketServer {
  -  static Category cat =
  -    Category.getInstance(SimpleSocketServer.class.getName());
  +  final static Logger logger = Logger.getLogger(SimpleSocketServer.class);
     static int port;
   
     public static void main(String[] argv) {
  @@ -53,16 +52,16 @@
       }
   
       try {
  -      cat.info("Listening on port " + port);
  +      logger.info("Listening on port " + port);
   
         ServerSocket serverSocket = new ServerSocket(port);
   
         while (true) {
  -        cat.info("Waiting to accept a new client.");
  +        logger.info("Waiting to accept a new client.");
   
           Socket socket = serverSocket.accept();
  -        cat.info("Connected to client at " + socket.getInetAddress());
  -        cat.info("Starting new socket node.");
  +        logger.info("Connected to client at " + socket.getInetAddress());
  +        logger.info("Starting new socket node.");
           new Thread(new SocketNode(socket, LogManager.getLoggerRepository()))
           .start();
         }
  
  
  
  1.3       +7 -7      logging-log4j/examples/src/trivial/Trivial.java
  
  Index: Trivial.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/examples/src/trivial/Trivial.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Trivial.java	27 Feb 2004 16:47:28 -0000	1.2
  +++ Trivial.java	6 Sep 2004 14:03:48 -0000	1.3
  @@ -17,7 +17,7 @@
   package trivial;
   
   import org.apache.log4j.BasicConfigurator;
  -import org.apache.log4j.Category;
  +import org.apache.log4j.Logger;
   import org.apache.log4j.NDC;
   
   
  @@ -47,29 +47,29 @@
   
    */
   public class Trivial {
  -  static Category cat = Category.getInstance(Trivial.class.getName());
  +  static Logger logger = Logger.getLogger(Trivial.class.getName());
   
     public static void main(String[] args) {
       BasicConfigurator.configure();
       NDC.push("Client #45890");
   
  -    cat.info("Awake awake. Put on thy strength.");
  +    logger.info("Awake awake. Put on thy strength.");
       Trivial.foo();
       InnerTrivial.foo();
  -    cat.info("Exiting Trivial.");
  +    logger.info("Exiting Trivial.");
     }
   
     static void foo() {
       NDC.push("DB");
  -    cat.debug("Now king David was old.");
  +    logger.debug("Now king David was old.");
       NDC.pop();
     }
   
     static class InnerTrivial {
  -    static Category cat = Category.getInstance(InnerTrivial.class.getName());
  +    static Logger logger = Logger.getLogger(InnerTrivial.class.getName());
   
       static void foo() {
  -      cat.info("Entered foo.");
  +      logger.info("Entered foo.");
       }
     }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message