activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r1082489 - in /activemq/trunk: activemq-core/src/main/java/org/apache/activemq/broker/ activemq-core/src/main/java/org/apache/activemq/broker/region/ activemq-core/src/main/java/org/apache/activemq/transport/vm/ activemq-core/src/test/java/...
Date Thu, 17 Mar 2011 13:53:39 GMT
Author: dejanb
Date: Thu Mar 17 13:53:38 2011
New Revision: 1082489

URL: http://svn.apache.org/viewvc?rev=1082489&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-3219 - more work on MDC logging

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/vm/VMTransportFactory.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/MessageReroutingTest.java
    activemq/trunk/activemq-core/src/test/resources/log4j.properties
    activemq/trunk/assembly/src/release/conf/log4j.properties

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java?rev=1082489&r1=1082488&r2=1082489&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java
Thu Mar 17 13:53:38 2011
@@ -93,6 +93,7 @@ import org.apache.activemq.transport.Tra
 import org.apache.activemq.util.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
 
 import static org.apache.activemq.thread.DefaultThreadPools.getDefaultTaskRunnerFactory;
 /**
@@ -300,6 +301,7 @@ public class TransportConnection impleme
     }
 
     public Response service(Command command) {
+        MDC.put("connector", connector.getUri().toString());
         Response response = null;
         boolean responseRequired = command.isResponseRequired();
         int commandId = command.getCommandId();
@@ -331,6 +333,7 @@ public class TransportConnection impleme
             }
             context = null;
         }
+        MDC.remove("connector");
         return response;
     }
 

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java?rev=1082489&r1=1082488&r2=1082489&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java
Thu Mar 17 13:53:38 2011
@@ -73,6 +73,7 @@ import org.apache.activemq.usage.UsageLi
 import org.apache.activemq.util.BrokerSupport;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
 
 /**
  * The Queue is a List of MessageEntry objects that are dispatched to matching
@@ -1362,6 +1363,7 @@ public class Queue extends BaseDestinati
      * @see org.apache.activemq.thread.Task#iterate()
      */
     public boolean iterate() {
+        MDC.put("destination", getName());
         boolean pageInMoreMessages = false;
         synchronized (iteratingMutex) {
 
@@ -1478,6 +1480,7 @@ public class Queue extends BaseDestinati
             if (pendingWakeups.get() > 0) {
                 pendingWakeups.decrementAndGet();
             }
+            MDC.remove("destination");
             return pendingWakeups.get() > 0;
         }
     }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/vm/VMTransportFactory.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/vm/VMTransportFactory.java?rev=1082489&r1=1082488&r2=1082489&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/vm/VMTransportFactory.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/vm/VMTransportFactory.java
Thu Mar 17 13:53:38 2011
@@ -39,6 +39,7 @@ import org.apache.activemq.util.URISuppo
 import org.apache.activemq.util.URISupport.CompositeData;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
 
 public class VMTransportFactory extends TransportFactory {
     
@@ -121,6 +122,7 @@ public class VMTransportFactory extends 
                             broker = BrokerFactory.createBroker(brokerURI);
                         }
                         broker.start();
+                        MDC.put("broker", broker.getBrokerName());
                     } catch (URISyntaxException e) {
                         throw IOExceptionSupport.create(e);
                     }
@@ -230,6 +232,7 @@ public class VMTransportFactory extends 
             if (broker != null) {
                 ServiceSupport.dispose(broker);
             }
+            MDC.remove("broker");
         }
     }
 

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/MessageReroutingTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/MessageReroutingTest.java?rev=1082489&r1=1082488&r2=1082489&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/MessageReroutingTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/MessageReroutingTest.java
Thu Mar 17 13:53:38 2011
@@ -44,7 +44,7 @@ public class MessageReroutingTest extend
         createBroker(new ClassPathResource("org/apache/activemq/usecases/rerouting-activemq-C.xml"));
         createBroker(new ClassPathResource("org/apache/activemq/usecases/rerouting-activemq-B.xml"));
         createBroker(new ClassPathResource("org/apache/activemq/usecases/rerouting-activemq-A.xml"));
-        
+
         brokers.get("broker-A").broker.waitUntilStarted();
     }
     

Modified: activemq/trunk/activemq-core/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/resources/log4j.properties?rev=1082489&r1=1082488&r2=1082489&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/resources/log4j.properties (original)
+++ activemq/trunk/activemq-core/src/test/resources/log4j.properties Thu Mar 17 13:53:38 2011
@@ -30,11 +30,13 @@ log4j.rootLogger=INFO, out, stdout
 # CONSOLE appender not used by default
 log4j.appender.stdout=org.apache.log4j.ConsoleAppender
 log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-10.10X{broker} - %-5p %-30.30c{1}
- %m%n
+log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] - %-5p %-30.30c{1} - %m%n
+#log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] - %-5p %-30.30c{1} - %-10.10X{broker}
%-20.20X{connector} %-10.10X{destination} - %m%n
 
 # File appender
 log4j.appender.out=org.apache.log4j.FileAppender
 log4j.appender.out.layout=org.apache.log4j.PatternLayout
-log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-10.10X{broker} - %-5p %-30.30c{1}
- %m%n
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] - %-5p %-30.30c{1} - %m%n
+#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] - %-5p %-30.30c{1} - %-10.10X{broker}
%-20.20X{connector} %-10.10X{destination} - %m%n
 log4j.appender.out.file=target/activemq-test.log
 log4j.appender.out.append=true

Modified: activemq/trunk/assembly/src/release/conf/log4j.properties
URL: http://svn.apache.org/viewvc/activemq/trunk/assembly/src/release/conf/log4j.properties?rev=1082489&r1=1082488&r2=1082489&view=diff
==============================================================================
--- activemq/trunk/assembly/src/release/conf/log4j.properties (original)
+++ activemq/trunk/assembly/src/release/conf/log4j.properties Thu Mar 17 13:53:38 2011
@@ -39,8 +39,6 @@ log4j.logger.org.apache.camel=INFO
 log4j.appender.console=org.apache.log4j.ConsoleAppender
 log4j.appender.console.layout=org.apache.log4j.PatternLayout
 log4j.appender.console.layout.ConversionPattern=%5p | %m%n
-# use the pattern below if you want to see mdc data, like broker name, etc
-#log4j.appender.console.layout.ConversionPattern=%5p | %-10.10X{broker} | %m%n
 log4j.appender.console.threshold=INFO
 
 # File appender
@@ -51,8 +49,15 @@ log4j.appender.logfile.maxBackupIndex=5
 log4j.appender.logfile.append=true
 log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
 log4j.appender.logfile.layout.ConversionPattern=%d | %-5p | %m | %c | %t%n
-# use the pattern below if you want to see mdc data, like broker name, etc
-#log4j.appender.logfile.layout.ConversionPattern=%d | %-10.10X{broker} | %-5p | %m | %c |
%t%n
+# use some of the following patterns to see MDC logging data
+#
+# %X{broker}
+# %X{connector}
+# %X{destination}
+#
+# e.g.
+#
+# log4j.appender.logfile.layout.ConversionPattern=%d | %-20.20X{connector} | %-5p | %m |
%c | %t%n
 
 ###########
 # Audit log



Mime
View raw message