json-log.express
A json log middleware for express. Powered by bunyan.
Installation
npm install json-log.express
Usage
At first, set your NODE_ENV
:
production
: JSON log output- others: Standard Apache combined log output
To use the requestLogger, place it in the front of all middlewares:
const jsonlog = app
To use the errorLogger, place it in the front of last error handler middleware:
const jsonlog = app
And a child logger will be attached to each request object:
const jsonlog = app app
Configuration
opts.name
The name of logger. Default is anonymous application
.
opts.level
The level of logger. Default is trace
.
opts.hidden
The fields to be hidden.
opts.levelFn
Function that translate statusCode into log level.
License
MIT