nomiddlename/log4js-node — pull request #113 by bitcloud (2013-02-08 14:11:02+00:00)
Title: add your own tokens to the patternLayout

Added the ability to add your own dynamic tokens to the patternLayout so you can easily extend your log with any additional information.

I currently use it to add the process pid to distinguish parallel running node instances logging to the same ressource.

I introduced a new %x field and used its specifier to address the token to use.

With this you should be able to add interesting status values like memory usage or any other status to your log messages to add some more context to them.

```javascript
var log4js = require("log4js");

var config = {
"appenders": [
{
"type": "console",
"layout": {
"type": "pattern",
"pattern": "%[%r (%x{pid}) %p %c -%] %m%n",
"tokens": {
"pid" : function() { return process.pid; }
}
}
}
]
};

log4js.configure(config, {});

var logger = log4js.getLogger("app");
logger.info("Test log message");
```