winston和loggly没有出现在loggly仪表板上

时间:2013-10-26 21:25:08

标签: node.js winston loggly

尝试用winston设置loggly,没有任何显示!我尝试了一个全能的源组:

loggly source group

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

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!'

可能出现什么问题?

1 个答案:

答案 0 :(得分:4)

Loggly发布了新版本 - Gen2。 Gen2尚未在winston-loggly包中实现。在与Loggly Team沟通后,我找到了基于this issue comment的解决方案:

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!');