Skip to content

openrm/express-logging-json

Repository files navigation

express-logging-json

A JSON logging helper for Express

Installation

npm install express-logging-json

Usage

A simple logging middleware example, with on-finished module:

const onFinished = require('on-finished');
const format = require('express-logging-json');

const options = {
    mask: {
        fields: ['headers.authorization']
    }
};

const app = express();

app.use((req, res, next) => {
    onFinished(res, err => {
        const log = format(req, res, options);
        log.err = err;
        console.info(log);
    });
    next();
});

About

A JSON logging helper for Express

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •