winston and loggly nothing shows up on loggly dash

2019-06-04 19:38发布

Trying to set up loggly with winston, and nothing shows up! I tried a catch-all source group:

loggly source group

And tried a simple info log:

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

What could be wrong?

1条回答
冷血范
2楼-- · 2019-06-04 20:31

Loggly released new version - Gen2. Gen2 is not implemented in winston-loggly package yet. After my communication with Loggly Team I found out a solution based on 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!');
查看更多
登录 后发表回答