xp-framework/xp-framework — pull request #124 by kiesel (2012-02-12 16:57:14+00:00)
Title: Add feature Nested Diagnostic Context to logging API

This patch adds NDC support to the logging API; there is information on NDC available at:

* http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/NDC.html
* http://wiki.apache.org/logging-log4j/NDCvsMDC

### Description
-----
Basically, this adds the option to add context information to log event at a different place in code than when emitting the event - for now, this context information is a string.

### Example
-----
In a scriptlet application you can add the sessionId as context information:

```php
getCategory();
$cat->pushContext('session='.$request->getSessionId());

// ...

$cat->info('Does this or that');
```

This will make the log line include the sessionId. These context information can then also be removed from the ```LogCategory``` at a later time.

### Implications
----
The NDC is stored along with a ```LogCategory```, it is not global. Also, if using a ```PatternLayout``` to print the context information, a ```%x``` must be included in the pattern.