Can we specify exact which level winston to log?

こ雲淡風輕ζ 提交于 2019-12-12 02:12:33

问题


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"
        })
    ]
});

回答1:


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



来源:https://stackoverflow.com/questions/42215559/can-we-specify-exact-which-level-winston-to-log

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!