在Winston for Node.js有没有办法从消息中抑制日志级别?

时间:2013-09-20 14:12:38

标签: express winston

我正在使用winston根据其他地方的各种评论来传输来自Express的日志消息,我的设置基本上是:

var express = require("express"),
    winston = require("winston");

// enable web server logging; pipe those log messages through winston
var requestLogger = new (winston.Logger)(
        {
            transports: [
                new (winston.transports.File)(
                    {
                        filename: "logs/request.log",
                        json: false,
                        timestamp: false
                    }
                )
            ]
        }
    ),
    winstonStream = {
        write: function(message, encoding) {
            requestLogger.info(message.replace(/(\r?\n)$/, ''));
        }
    };

this.use(express.logger({stream: winstonStream}));

但是我想要一种方法来抑制日志级别的输出,因为我知道这个特定的记录器它总是“info”。所以而不是:

info: 127.0.0.1 - - [Fri, 20 Sep 2013 13:48:02 GMT] "POST /v1/submission HTTP/1.1" 200 261 "http://localhost:8887/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.65 Safari/537.36"

我会得到:

127.0.0.1 - - [Fri, 20 Sep 2013 13:48:02 GMT] "POST /v1/submission HTTP/1.1" 200 261 "http://localhost:8887/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.65 Safari/537.36"

0 个答案:

没有答案