1

尝试使用winston 设置loggly,但没有任何显示!我尝试了一个包罗万象的源组:

日志源组

并尝试了一个简单的信息日志:

winston = require 'winston'
Loggly = require('winston-loggly').Loggly

winston.add Loggly, {
  subdomain: "my-subdomain",
  inputToken: "my-input-token-ihawof9ahw3fo9ahwe",
  json: true
}

winston.info 'Hello Loggly!'

有什么问题?

4

1 回答 1

4

Loggly 发布新版本 - Gen2。Gen2 尚未在 winston-loggly 包中实现。在与 Loggly 团队沟通后,我找到了基于此问题评论的解决方案:

var winston = require('winston');

require('winston-loggly');

var logger = new (winston.Logger)({
    transports: [
      //new (winston.transports.Console)(),
      new (winston.transports.Loggly)({
            inputToken: 'mytoken',
            subdomain: 'mydomain',
            auth: { username: 'myusername', password: 'pswd' },
            json: true
        })
    ]
});

Object.defineProperty(logger.transports.loggly.client.config, 'inputUrl', {
    value: 'https://logs-01.loggly.com/inputs/',
    enumerable: true,
    configurable: true
});

logger.info('Hello Loggly!');
于 2013-11-04T12:58:22.067 回答