Node-bunyan: support question - duplicate log entries

Created on 25 Jan 2016  路  2Comments  路  Source: trentm/node-bunyan

I added this question on SO

http://stackoverflow.com/questions/35002880/bunyan-duplicate-logging-in-node-js-module

for some reason in multiple projects I having some duplicate log entries and I don't know why and haven't seen this problem before, but I don't believe I am on a new version of Bunyan and I doubt it's a problem with the Bunyan module. Please see SO question for details.

Any idea on why I might be seeing this, given my simple Bunyan configuration?

Thanks!

Type-Question Component-Lib Resolution-Fixed

Most helpful comment

Well to answer one of your questions on the SO post about log levels. The log level is a minimum log level not an exclusive log level. If you have a stream configured for 'info', you will get all INFO logs and anything _more_ severe ( WARN, ERROR, etc)

As for your particular case double log case, the error configuration WOULD double log in the terminal if you logged with an error level log.

// test.js
var bunyan = require('bunyan')
var logger = bunyan.createLogger({
    name: 'test',
    streams: [
        {
            level: 'info',
            stream: process.stdout
        },
        {
            level: 'error',
            stream: process.stderr
        }
    ]
})

logger.error('hello!')

Would output:

$ node test.js 
{"name":"test","hostname":"<hostname>","pid":<pid>,"level":50,"msg":"hello!","time":"2016-01-29T23:00:00.843Z","v":0}
{"name":"test","hostname":"<hostname>","pid":<pid>,"level":50,"msg":"hello!","time":"2016-01-29T23:00:00.843Z","v":0}

Hope this helps!

All 2 comments

Well to answer one of your questions on the SO post about log levels. The log level is a minimum log level not an exclusive log level. If you have a stream configured for 'info', you will get all INFO logs and anything _more_ severe ( WARN, ERROR, etc)

As for your particular case double log case, the error configuration WOULD double log in the terminal if you logged with an error level log.

// test.js
var bunyan = require('bunyan')
var logger = bunyan.createLogger({
    name: 'test',
    streams: [
        {
            level: 'info',
            stream: process.stdout
        },
        {
            level: 'error',
            stream: process.stderr
        }
    ]
})

logger.error('hello!')

Would output:

$ node test.js 
{"name":"test","hostname":"<hostname>","pid":<pid>,"level":50,"msg":"hello!","time":"2016-01-29T23:00:00.843Z","v":0}
{"name":"test","hostname":"<hostname>","pid":<pid>,"level":50,"msg":"hello!","time":"2016-01-29T23:00:00.843Z","v":0}

Hope this helps!

@rooftopsparrow Thanks for answering!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ronkorving picture ronkorving  路  5Comments

raybooysen picture raybooysen  路  3Comments

kbirger picture kbirger  路  4Comments

yelworc picture yelworc  路  5Comments

JustinMcConnell picture JustinMcConnell  路  9Comments