Author: dkulp Date: Mon Nov 14 15:43:24 2011 New Revision: 1201757 URL: http://svn.apache.org/viewvc?rev=1201757&view=rev Log: Merged revisions 1185952 via svnmerge from https://svn.apache.org/repos/asf/camel/trunk
........ r1185952 | ningjiang | 2011-10-18 23:09:42 -0400 (Tue, 18 Oct 2011) | 1 line CAMEL-4547 Add camelContextId to the mdc logging keys ........ Modified: camel/branches/camel-2.8.x/ (props changed) camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/MDCUnitOfWork.java Propchange: camel/branches/camel-2.8.x/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/MDCUnitOfWork.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/MDCUnitOfWork.java?rev=1201757&r1=1201756&r2=1201757&view=diff ============================================================================== --- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/MDCUnitOfWork.java (original) +++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/MDCUnitOfWork.java Mon Nov 14 15:43:24 2011 @@ -36,6 +36,7 @@ public class MDCUnitOfWork extends Defau public static final String MDC_EXCHANGE_ID = "exchangeId"; public static final String MDC_CORRELATION_ID = "correlationId"; public static final String MDC_ROUTE_ID = "routeId"; + public static final String MDC_CAMEL_CONTEXT_ID = "camelContextId"; public static final String MDC_TRANSACTION_KEY = "transactionKey"; private static final Logger LOG = LoggerFactory.getLogger(MDCUnitOfWork.class); @@ -44,6 +45,7 @@ public class MDCUnitOfWork extends Defau private final String originalExchangeId; private final String originalCorrelationId; private final String originalRouteId; + private final String originalCamelContextId; private final String originalTransactionKey; public MDCUnitOfWork(Exchange exchange) { @@ -54,10 +56,13 @@ public class MDCUnitOfWork extends Defau this.originalBreadcrumbId = MDC.get(MDC_BREADCRUMB_ID); this.originalCorrelationId = MDC.get(MDC_CORRELATION_ID); this.originalRouteId = MDC.get(MDC_ROUTE_ID); + this.originalCamelContextId = MDC.get(MDC_CAMEL_CONTEXT_ID); this.originalTransactionKey = MDC.get(MDC_TRANSACTION_KEY); // must add exchange id in constructor MDC.put(MDC_EXCHANGE_ID, exchange.getExchangeId()); + // the camel context id is from exchange + MDC.put(MDC_CAMEL_CONTEXT_ID, exchange.getContext().getName()); // and add optional correlation id String corrId = exchange.getProperty(Exchange.CORRELATION_ID, String.class); if (corrId != null) { @@ -145,6 +150,11 @@ public class MDCUnitOfWork extends Defau } else { MDC.remove(MDC_ROUTE_ID); } + if (this.originalCamelContextId != null) { + MDC.put(MDC_CAMEL_CONTEXT_ID, originalCamelContextId); + } else { + MDC.remove(MDC_CAMEL_CONTEXT_ID); + } if (this.originalTransactionKey != null) { MDC.put(MDC_TRANSACTION_KEY, originalTransactionKey); } else { @@ -168,12 +178,14 @@ public class MDCUnitOfWork extends Defau private final String exchangeId; private final String correlationId; private final String routeId; + private final String camelContextId; private MDCCallback(AsyncCallback delegate) { this.delegate = delegate; this.exchangeId = MDC.get(MDC_EXCHANGE_ID); this.breadcrumbId = MDC.get(MDC_BREADCRUMB_ID); this.correlationId = MDC.get(MDC_CORRELATION_ID); + this.camelContextId = MDC.get(MDC_CAMEL_CONTEXT_ID); String routeId = MDC.get(MDC_ROUTE_ID); if (routeId != null) { @@ -200,6 +212,9 @@ public class MDCUnitOfWork extends Defau if (routeId != null) { MDC.put(MDC_ROUTE_ID, routeId); } + if (camelContextId != null) { + MDC.put(MDC_CAMEL_CONTEXT_ID, camelContextId); + } } } finally { // muse ensure delegate is invoked