Skip to content

hamtie/winston-graylog2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

winston-graylog2

A graylog2 transport for winston

Install

npm install winston-graylog2

Usage

A convenience wrapper may be supported in the future but for now the easiest way to use is to instantiate a new winston logger and add winston-graylog2 as a transport.

var winston = require("winston"),
graylog2 = require("winston-graylog2").Graylog2,
levels = winston.config.syslog.levels;

// Initialize logger
var logger = new (winston.Logger)({
  levels: levels,
  transports: [new (graylog2)()]
});

// Log something
logger.log('emerg', 'FIX THIS NOW');
logger.emerg('NO RLY');

The default winston logger settings should not be used because Graylog2 expects the log levels to be syslog levels. All else should function the same as other loggers.

Meta data

By default, the pid and cwd are added to the graylog meta fields. All other meta fields passed to winston get sent along in the meta data as well.

Transport options

  1. host [value]: 'localhost'
  2. port [value]: 12201
  3. level [value]: 'info'
  4. facility [value]: 'winston-graylog2'
  5. timestamp [value or function]: function() { ((new Date()).getTime()/1000).toFixed(2); }; (current time in seconds)

TODO

  1. Add chunking to messages
  2. More pleasant way to flatten meta fields without changing logger api

References

  1. winston
  2. node-graylog
  3. winston-riak
  4. gelf spec
  5. graylog2

Notes

There is another winston-graylog2 module, http://github.com/flite/winston-graylog2, that was made independently. I opted to keep this repo separate for a few reasons, one of them being that only a subset of the syslog logging levels are exposed in the other project.

About

A graylog2 transport for winston

Resources

Stars

Watchers

Forks

Packages

No packages published