Search code examples
node.jswinstonloggly

How can I stop Loggly from printing to stdout (or stderr) and just sending the logs to the cloud?


We're using Loggly for logging and generally very happy with it, but having upgraded to the Winston methodology I'm now finding that all my logging is not just going to the Loggly server but also being console.loged out to stdout (or stderr, whichever that is).

There's not a whole lot to the documentation, and I'm not seeing a way to shut this up. The whole *point of this exercise is I don't want to keep all these logs on my local machine, which is where they will wind up if they're heading to the console.

I tried deleting the Console object from the winston.transports object, but that hasn't done anything.

I'm kind of out of ideas.


Solution

  • If removing default Console transport doesn't work, you can always create your own logger instance and use it.

    var winston  = require('winston');
    require('winston-loggly');
    
    var logger = new (winston.Logger)({
      transports: [
        new (winston.transports.Loggly)({
          inputToken: "TOKEN",
          subdomain: "SUBDOMAIN",
          tags: ["Winston-NodeJS"],
          json:true
        })
      ]
    });
    
    module.exports = logger;
    

    You can find more information in winston documentation. Section Using the Default Logger shows you the way to remove default console transport. The Instantiating your own logger section has information about creating a custom logger.