access logger middleware using fluentd for express.js
$ npm install express-fluent-logger
var app = require('express')();
var logger = require('express-fluent-logger');
app.use(logger());
app.get('/', function(req, res) {
res.send('hello world!');
});
app.listen(3000);
- tag: String of tag name on fluentd. (default:
debug
) - options: Object of fluentd connection. (default:
{ host: '127.0.0.1', port: 24224, timeout: 3.0 }
)
This middleware will record the http response header, if you specify options.responseHeaders
as following.
var app = require('express')();
var logger = require('express-fluent-logger');
app.use(logger)('tagName', { host: '127.0.0.1', port: 24224, timeout: 3.0, responseHeaders: ['x-userid'] }));
app.get('/', function(req, res) {
res.send('hello world!');
});
app.listen(3000);
$ fluentd -c test/fluent.conf &
$ npm test