A Syslog transport for winston. I started out with https://github.com/indexzero/winston-syslog, but plugged in node-syslog
.
$ npm install winston
$ npm install winston-syslog2
To use the Syslog transport in winston, you simply need to require it and then either add it to an existing winston logger or pass an instance to a new winston logger:
var winston = require('winston');
//
// Requiring `winston-syslog` will expose
// `winston.transports.Syslog`
//
require('winston-syslog');
winston.add(winston.transports.Syslog, {level: ‘emerg’});
Because syslog only allows a subset of the levels available in winston, levels that do not match will be ignored. Therefore, in order to use winston-syslog
effectively, you should indicate to winston that you want to use the syslog levels:
var winston = require('winston');
winston.setLevels(winston.config.syslog.levels);
The Syslog
transport will only log to the level that are available in the syslog protocol. These are (in increasing order of severity):
- debug
- info
- notice
- warning
- error
- crit
- alert
- emerg
There is currently a bug in winston where the syslog levels are mapped backwards. Because of this, you will probably want to set the log level to ‘emerg’ as seen in the example above.