[logback-dev] svn commit: r1204 - in logback/trunk/logback-classic/src: main/java/ch/qos/logback/classic/net test/java/ch/qos/logback/classic/net

noreply.seb at qos.ch noreply.seb at qos.ch
Fri Jan 12 15:57:01 CET 2007


Author: seb
Date: Fri Jan 12 15:57:00 2007
New Revision: 1204

Added:
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSQueueAppenderTestApp.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSTopicAppenderTestApp.java
Modified:
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSQueueSink.java
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSTopicSink.java

Log:
JMS*Appender test apps are back for performance testing

Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSQueueSink.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSQueueSink.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSQueueSink.java	Fri Jan 12 15:57:00 2007
@@ -45,20 +45,20 @@
   private Logger logger = (Logger)LoggerFactory.getLogger(JMSTopicSink.class);
 
   static public void main(String[] args) throws Exception {
-    if (args.length != 4) {
+    if (args.length != 2) {
       usage("Wrong number of arguments.");
     }
 
     String qcfBindingName = args[0];
     String queueBindingName = args[1];
-    String username = args[2];
-    String password = args[3];
+//    String username = args[2];
+//    String password = args[3];
 
     LoggerContext loggerContext = (LoggerContext) LoggerFactory
         .getILoggerFactory();
     ContextInitializer.autoConfig(loggerContext);
 
-    new JMSQueueSink(qcfBindingName, queueBindingName, username, password);
+    new JMSQueueSink(qcfBindingName, queueBindingName, null, null);
 
     BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
     // Loop until the word "exit" is typed
@@ -138,7 +138,7 @@
     System.err
         .println("Usage: java "
             + JMSTopicSink.class.getName()
-            + " QueueConnectionFactoryBindingName QueueBindingName username password");
+            + " QueueConnectionFactoryBindingName QueueBindingName");
     System.exit(1);
   }
 }

Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSTopicSink.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSTopicSink.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSTopicSink.java	Fri Jan 12 15:57:00 2007
@@ -45,20 +45,20 @@
   private Logger logger = (Logger)LoggerFactory.getLogger(JMSTopicSink.class);
 
   static public void main(String[] args) throws Exception {
-    if (args.length != 4) {
+    if (args.length != 2) {
       usage("Wrong number of arguments.");
     }
 
     String tcfBindingName = args[0];
     String topicBindingName = args[1];
-    String username = args[2];
-    String password = args[3];
+//    String username = args[2];
+//    String password = args[3];
 
     LoggerContext loggerContext = (LoggerContext) LoggerFactory
         .getILoggerFactory();
     ContextInitializer.autoConfig(loggerContext);
 
-    new JMSTopicSink(tcfBindingName, topicBindingName, username, password);
+    new JMSTopicSink(tcfBindingName, topicBindingName, null, null);
 
     BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
     // Loop until the word "exit" is typed
@@ -109,7 +109,6 @@
 
   public void onMessage(javax.jms.Message message) {
     LoggingEvent event;
-    System.out.println("xxxx onMessage called");
     try {
       if (message instanceof ObjectMessage) {
         ObjectMessage objectMessage = (ObjectMessage) message;
@@ -139,7 +138,7 @@
     System.err
         .println("Usage: java "
             + JMSTopicSink.class.getName()
-            + " TopicConnectionFactoryBindingName TopicBindingName username password");
+            + " TopicConnectionFactoryBindingName TopicBindingName");
     System.exit(1);
   }
 }

Added: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSQueueAppenderTestApp.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSQueueAppenderTestApp.java	Fri Jan 12 15:57:00 2007
@@ -0,0 +1,48 @@
+package ch.qos.logback.classic.net;
+
+import org.slf4j.LoggerFactory;
+
+import ch.qos.logback.classic.Logger;
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.core.util.StatusPrinter;
+
+public class JMSQueueAppenderTestApp {
+  
+  public static void main(String[] args) {
+    Logger logger = (Logger)LoggerFactory.getLogger(JMSTopicAppenderTestApp.class);
+    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
+    lc.shutdownAndReset();
+    
+    JMSQueueAppender appender = new JMSQueueAppender();
+    appender.setContext(lc);
+    appender.setName("jmsQueue");
+    appender.setInitialContextFactoryName("org.apache.activemq.jndi.ActiveMQInitialContextFactory");
+    //appender.setPassword("");
+    appender.setProviderURL("tcp://localhost:61616");
+    //appender.setSecurityCredentials("");
+    //appender.setSecurityPrincipalName("");
+    appender.setQueueBindingName("MyQueue");
+    appender.setQueueConnectionFactoryBindingName("ConnectionFactory");
+    //appender.setURLPkgPrefixes("");
+    //appender.setUserName("");
+    
+    appender.start();
+    logger.addAppender(appender);
+    
+    //JIT
+    for (int i = 0; i < 10000; i++) {
+      logger.debug("** Hello world. n=" + i);
+    }
+    
+    long before = System.nanoTime();
+    for (int i = 0; i < 10000; i++) {
+      logger.debug("** Hello world. n=" + i);
+    }
+    long after = System.nanoTime();
+    
+    System.out.println("Time per logs for 10'000 logs: " + (after-before)/10000);
+    
+    StatusPrinter.print(lc.getStatusManager());
+  }
+
+}
\ No newline at end of file

Added: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSTopicAppenderTestApp.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSTopicAppenderTestApp.java	Fri Jan 12 15:57:00 2007
@@ -0,0 +1,49 @@
+package ch.qos.logback.classic.net;
+
+import org.slf4j.LoggerFactory;
+
+import ch.qos.logback.classic.Logger;
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.core.util.StatusPrinter;
+
+public class JMSTopicAppenderTestApp {
+  
+  public static void main(String[] args) {
+    Logger logger = (Logger)LoggerFactory.getLogger(JMSTopicAppenderTestApp.class);
+    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
+    lc.shutdownAndReset();
+    
+    JMSTopicAppender appender = new JMSTopicAppender();
+    appender.setContext(lc);
+    appender.setName("jmsTopic");
+    appender.setInitialContextFactoryName("org.apache.activemq.jndi.ActiveMQInitialContextFactory");
+    //appender.setPassword("");
+    appender.setProviderURL("tcp://localhost:61616");
+    //appender.setSecurityCredentials("");
+    //appender.setSecurityPrincipalName("");
+    appender.setTopicBindingName("MyTopic");
+    appender.setTopicConnectionFactoryBindingName("ConnectionFactory");
+    //appender.setURLPkgPrefixes("");
+    //appender.setUserName("");
+    
+    appender.start();
+    logger.addAppender(appender);
+    
+    
+    //JIT
+    for (int i = 0; i < 10000; i++) {
+      logger.debug("** Hello world. n=" + i);
+    }
+    
+    long before = System.nanoTime();
+    for (int i = 0; i < 10000; i++) {
+      logger.debug("** Hello world. n=" + i);
+    }
+    long after = System.nanoTime();
+    
+    System.out.println("Time per logs for 10'000 logs: " + (after-before)/10000);
+    
+    StatusPrinter.print(lc.getStatusManager());
+  }
+
+}
\ No newline at end of file



More information about the logback-dev mailing list