Update readme to describe hook.io usage

date-rolling-file-appender
Danny Brain 13 years ago
parent 3b77a42706
commit f82ecf8f2a

@ -100,6 +100,62 @@ The options object that is passed to log4js.connectLogger supports a format stri
app.use(log4js.connectLogger(logger, { level: log4js.levels.INFO, format: ':method :url' }));
});
## hook.io logger
A [hook.io](https://github.com/hookio) logger has been added to logjs by [dbrain](https://github.com/dbrain). This allows multiple worker processes to log through a single master process, avoiding issues with rolling etc. in a clustered environment.
This was mainly created for [cluster](https://github.com/LearnBoost/cluster), but you can adapt the example to match your needs, you know, if it fits them.
<pre>
#### log4js-master.json ####
{
"appenders": [{
"type": "logLevelFilter",
"level": "DEBUG",
"appender": {
"type": "hookio",
"name": "hookio-logger",
"mode": "master",
"debug": false,
"appender": {
"type": "file",
"filename": "muffin.log",
"maxLogSize": 104857600,
"backups": 10,
"pollInterval": 15
}
}
}]
}
#### log4js-worker.json ####
{
"appenders": [{
"type": "logLevelFilter",
"level": "DEBUG",
"appender": {
"type": "hookio",
"name": "hookio-logger",
"mode": "worker",
"debug": false
}
}]
}
#### ilikebeans.js ####
var cluster = require('cluster');
var hookCluster = cluster('./doyoulikebeans');
// Perform the once off configuration depending on type of cluster
if (aboutCluster.isMaster) {
require('log4js').configure('log4js-master.json');
} else {
require('log4js').configure('log4js-worker.json');
}
// Standard cluster startup
hookCluster
.use(cluster.logger('run/logs'))
.use(cluster.pidfiles('run/pids'))
.listen(3000);
</pre>
## author (of this node version)
Gareth Jones (csausdev - gareth.jones@sensis.com.au)

Loading…
Cancel
Save