mirror of https://github.com/apache/activemq.git
https://issues.apache.org/jira/browse/AMQ-3219 - more work on MDC logging
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1082489 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
986ed145a7
commit
2b456ddbd0
|
@ -93,6 +93,7 @@ import org.apache.activemq.transport.TransportFactory;
|
|||
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 implements Connection, Task, CommandVisitor {
|
|||
}
|
||||
|
||||
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 implements Connection, Task, CommandVisitor {
|
|||
}
|
||||
context = null;
|
||||
}
|
||||
MDC.remove("connector");
|
||||
return response;
|
||||
}
|
||||
|
||||
|
|
|
@ -73,6 +73,7 @@ import org.apache.activemq.usage.UsageListener;
|
|||
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 BaseDestination implements Task, UsageListener {
|
|||
* @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 BaseDestination implements Task, UsageListener {
|
|||
if (pendingWakeups.get() > 0) {
|
||||
pendingWakeups.decrementAndGet();
|
||||
}
|
||||
MDC.remove("destination");
|
||||
return pendingWakeups.get() > 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.apache.activemq.util.URISupport;
|
|||
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 TransportFactory {
|
|||
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 TransportFactory {
|
|||
if (broker != null) {
|
||||
ServiceSupport.dispose(broker);
|
||||
}
|
||||
MDC.remove("broker");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ public class MessageReroutingTest extends JmsMultipleBrokersTestSupport {
|
|||
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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue