Can we specify exact which level winston to log?

2019-09-05 17:44发布

I have a logger of winston below. when I try to debug my app. However when I debug my logs, all my screen gets filled with 'error' level. All my useful logs I have put into 'info'. Is there a way that I can only checking only my 'info' level logs?

var logger = new (winston.Logger)({
    transports: [
        new (winston.transports.Console)({
            'timestamp': true,
            level: "info"
        })
    ]
});

标签: winston
1条回答
欢心
2楼-- · 2019-09-05 17:59

You can use this handy fork of winston (the downside is that it was forked 3 years ago and doesn't seem to be actively maintained any longer): https://www.npmjs.com/package/winston-levelonly

Alternatively, you can define a custom transport, like shown here: https://github.com/winstonjs/winston/pull/628

查看更多
登录 后发表回答