Search code examples
node.jssails.jswinstongraylog2

Graylog logging in sails using winston-graylog2


In my sailsjs Application, I am logging to a file using winston. Logs are getting stored properly in file. I have added a graylog transport but i am unable to get any logs in graylog. Following is my code in config/log.js

var logger = new (winston.Logger)({
        transports: [
                     new (winston.transports.Console)( { } ),
                     new (winston.transports.File)({ filename: 'application.log',
                                                     levels  : 'info',
                                                     json    : false,
                                                     colorize: true
                         }),
                     new (WinstonGraylog2)({
                      name            : 'Graylog',
                      level           : 'info',
                      silent          : false,
                      handleExceptions: false,
                      prelog          : function (msg) {
                        return msg.trim();
                      },
                      graylog         : {
                        servers   : [{
                          host: config.graylogHostName,
                          port: config.graylogPort
                        }],
                        facility: config.graylogFacility,
                        bufferSize: 1400
                      }
                     })
                    ]
    });

Please help with the correct config to get the logs in graylog.?


Solution

  • There was some syntax error in my code, above config was working fine.