班扬较高级别的日志记录到较低级别的流中



我正在尝试在我的nodejs应用程序中使用bunyan,但是我坚持这种奇怪的行为。像这样定义记录器:

var info = bunyan.createLogger({
    name: 'Test',
    streams: [
        {
            path: './logger/fatal.log',
            level: 'fatal'
        },
        {
            path: './logger/error.log',
            level: 'error'
        },
        {
            path: './logger/warn.log',
            level: 'warn'
        },
        {
            path: './logger/info.log',
            level: 'info'
        },
        {
            path: './logger/debug.log',
            level: 'debug'
        },
        {
            path: './logger/trace.log',
            level: 'trace'
        }
    ]
});

我在这样的函数中调用它们:

var func = function () {
    info.fatal("FATAL!");
    info.error("ERROR!");
    info.warn("WARN!");
    info.debug("DEBUG!");
    info.info("INFO");
    info.trace("TRACE");
}

现在可预测的行为将是致命.log{"name":"Test","hostname":"ENIGMA","pid":16793,"level":60,"msg":"FATAL!","time":"2016-01-21T09:12:34.293Z","v":0}

错误.log {"name":"Test","hostname":"ENIGMA","pid":16793,"level":50,"msg":"ERROR!","time":"2016-01-21T09:12:34.295Z","v":0}等等。

但是,在我的申请中,致命.log{"name":"Test","hostname":"ENIGMA","pid":16793,"level":60,"msg":"FATAL!","time":"2016-01-21T09:12:34.293Z","v":0}

错误.log{"name":"Test","hostname":"ENIGMA","pid":16793,"level":60,"msg":"FATAL!","time":"2016-01-21T09:12:34.293Z","v":0} {"name":"Test","hostname":"ENIGMA","pid":16793,"level":50,"msg":"ERROR!","time":"2016-01-21T09:12:34.295Z","v":0}

警告.log{"name":"Test","hostname":"ENIGMA","pid":16793,"level":60,"msg":"FATAL!","time":"2016-01-21T09:12:34.293Z","v":0} {"name":"Test","hostname":"ENIGMA","pid":16793,"level":50,"msg":"ERROR!","time":"2016-01-21T09:12:34.295Z","v":0} {"name":"Test","hostname":"ENIGMA","pid":16793,"level":40,"msg":"WARN!","time":"2016-01-21T09:12:34.296Z","v":0}

等等。

较高级别的日志正在进入较低的流。如何防止这种行为并使每个级别登录到其自己的特定文件中?(我也在节点班扬报告了一个问题)

这是记录器设计的一部分。较高的级别也将始终登录到较低的级别。因此,最后一关将是其中最冗长的。

相关内容

  • 没有找到相关文章

最新更新