Closed eladmoshe closed 10 years ago
Hi there is an option field called logger
which is provide for flexible customized logger.
If you want to use a logchild, you can do like this:
var log = bunyan.createLogger({
name: 'myapp',
serializers: { // add serializers for req, res and err
req: bunyan.stdSerializers.req,
req: bunyan.stdSerializers.res,
err: bunyan.stdSerializers.err
}
});
var express_loggger = log.child({type: 'express', key: value});
app.use(require('express-bunyan-logger')({
logger: express_logger
});
But in that way, you might want add serializers
by yourself.
Awesome, thanks! Using your code sample, I was able to achieve something very similar to express standard output in bunyan format, only changing the last line to:
app.use(require('express-bunyan-logger')({logger: express_logger, excludes:['user-agent','body','short-body','req-headers','res-headers','req','res','incoming']}));
It would be really great if it was possible to define some field to be added to all log jsons. This is similar to Bunyan's log.child({key:value}) method which creates a log that appends fields to all log items from that logger.
https://github.com/trentm/node-bunyan#logchild