Search code examples
node.jswinstonloggly

winston and loggly nothing shows up on loggly dashboard


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?


Solution

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