Hapi Bunyan Plugin
Integrates bunyan with Hapi.js by wiring
a bunyan Logger instance into the published server events.
Allows structured json logging of the Hapi.Server generated log messages. Using
server.log() and request.log() will be
routed through the bunyan Logger as well.
Usage
var Hapi = require('hapi'),
HapiBunyan = require('hapi-bunyan'),
bunyan = require('bunyan');
var server = new Hapi.Server(),
log = bunyan.createLogger({
name: 'my-application',
level: 'debug'
});
server.connection({ port: 8000 });
server.register({
register: HapiBunyan,
options: {
log: log
}
});
// other server configuration, routes, etc.
server.start();
Configuration
The options object used when registering the plugin takes the following properties:
- log - the bunyan Logger instance. (required)
- logInternal - boolean value, defaults to false. Set to true to enable
logging of Hapi.Server internal events.
License
MIT. See LICENSE.txt.