Index: src/main/php/LoggerMDC.php =================================================================== --- src/main/php/LoggerMDC.php (revision 159) +++ src/main/php/LoggerMDC.php (revision 160) @@ -104,6 +104,18 @@ } /** + * Get the contex map. + * + *
This method has no side effects.
+ * + * @return array + * @static + */ + public static function getMap() { + return self::$map; + } + + /** * Remove the the context identified by the key parameter. * * It only affects user mappings, not $_ENV or $_SERVER. Index: src/main/php/layouts/LoggerLayoutXml.php =================================================================== --- src/main/php/layouts/LoggerLayoutXml.php (revision 159) +++ src/main/php/layouts/LoggerLayoutXml.php (revision 160) @@ -135,6 +135,18 @@ $this->appendEscapingCDATA($buf, $ndc); $buf .= "]]>{$this->_namespacePrefix}:NDC>".PHP_EOL; } + + $mdcMap = $event->getMDCMap(); + if (is_array($mdcMap)) { + $buf .= "<{$this->_namespacePrefix}:properties>".PHP_EOL; + foreach ($mdcMap as $name=>$value) { + $buf .= "<{$this->_namespacePrefix}:data ". + "name=\"" . $name . "\" ". + "value=\"" . $value . "\" ". + "/>".PHP_EOL; + } + $buf .= "{$this->_namespacePrefix}:properties>".PHP_EOL; + } if ($this->getLocationInfo()) { $locationInfo = $event->getLocationInformation(); Index: src/main/php/LoggerLoggingEvent.php =================================================================== --- src/main/php/LoggerLoggingEvent.php (revision 159) +++ src/main/php/LoggerLoggingEvent.php (revision 160) @@ -272,6 +272,14 @@ public function getMDC($key) { return LoggerMDC::get($key); } + + /** + * Returns the entire context. + * @return array + */ + public function getMDCMap () { + return LoggerMDC::getMap(); + } /** * Render message.