winston: Http transport don't work

I have this logger(version 2.4.0):

const winston = require('winston');

const logger = new winston.Logger({
    transports: [
        new winston.transports.Http({
            host: '127.0.0.1',
            port: 8787,
        }),
    ],
});

With this http server receiving the payload:

const http = require('http');

const server = http.createServer(function (req, res) {
    if (req.method == 'POST') {
        let body = '';
        req.on('data', function (data) {
            body += data;
        });
        req.on('end', function () {
            console.log('Body: ' + body);
        });
    }
    res.end();
});

server.listen(8787, '127.0.0.1');

I forced a error using logger.error(new Error('test')); and only receive this in the logger:

Body: {"method":"collect","params":{"level":"error","message":"","meta":{}}}

Any idea?

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Comments: 16 (1 by maintainers)

Most upvoted comments

I have the same situation.