Skip to content

stoshiya/express-fluent-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

express-fluent-logger

NPM Version NPM Downloads Build Status Test Coverage Maintainability NPM Dependency Known Vulnerabilities

access logger middleware using fluentd for express.js

Install

$ npm install express-fluent-logger

Example

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);

Parameters

  • 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 })

Logging HTTP response headers

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);

Test

$ fluentd -c test/fluent.conf &
$ npm test

License

MIT

About NodeJS version

This package is compatible with NodeJS versions >= 6.