xp-framework/xp-framework — pull request #239 by mrosoiu (2013-02-21 15:35:02+00:00)
Title: Log context

Hi,

This pull request adds context information to the logging mechanism. The following pull requests are related to this one: #124, #146 and #174.

Two log context implementations are provided:

- `NestedLogContext` (same as [log4j NDC](http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/NDC.html))
- `MappedLogContext` (same as [log4j MDC](http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/MDC.html))

More custom implementations can be added as needed; either in the framework or in an XP-Framework project.

To add context information to the logging mechanism, `log.ini` can be modified as follow:

```ini
[default]
appenders="util.log.FileAppender"
context="util.log.context.MappedLogContext"
appender.util.log.FileAppender.params="filename"
appender.util.log.FileAppender.param.filename="/var/log/xp/default.log"
```

This pull request also adds environment information to LogContext (only if the LogCategory has a LogContext attached):

- `hostname`
- `runner`
- `instance`
- `reqource`
- `params`.

This info is automatically injected by the runners. It is not used anywhere in the logging output, but some custom `LogContext` implementation might make use of this information in it's `format()` method. We intend to use it in a custom Appender for the ErrorTool NG log server. If you think this adds too much overhead, I can remove it.