A message oriented transport for Winston based on axon

npm install winston-axon
3 downloads in the last day
25 downloads in the last week
93 downloads in the last month


This is a message oriented Transport for winston based on axon .


If you have a large application with a lot of independent services, you can easy log every service with a unique socket logging endpoint using axon as message-oriented library.


Install winston-axon as usual:

$ npm install winston-axon


When you add winston-axon to your winston logger, you can provide this options:

  • host: (Default: Remote host of the socket logging endpoint
  • port: (Default: 3000) Remote port of the socket logging endpoint
  • timestamp: (Default false) Boolean flag indicating if we should add a timestamp to the output. If function is specified, its return value will be used instead of timestamps.


To use this plugin you must have a socket logging endpoint (server) and at least a logger (client).


Create your own server use this simple example:

// dependencies
var axon = require('axon');
var winston = require('winston');

// set socket
var sock = axon.socket('pull');

// create a customized Console Transport
var consoleTransport = new winston.transports.Console({
  level: 'debug',
  colorize: true,
  timestamp: false

// create new Logger
var logger = new (winston.Logger)({
  transports: [
    consoleTransport // add other Transport types if you need
  exitOnError: true

// wait for incoming logs
sock.on('message', function(msg) {
  logger.log(msg.level, msg);
});'server started');

Save as server.js and start the server:

$ node server.js

info: server started


Into the client simply add winston-axon as new Transport to your winston instance:

var winston = require('winston');
var Axon = require('winston-axon').Axon;
winston.add(Axon, { level: 'debug', timestamp: new Date() });
winston.debug({ message: 'Test Object Log Message', error: false });
winston.log('info', 'Test Log Message', { anything: 'This is metadata' });

Save as client.js and start it:

$ node client.js

info: Test Log Message anything=This is metadata

Now in your previous terminal session (that when the server is running) you see this new lines:

debug:  level=debug, message=Debug text only message, timestamp=2014-03-14T14:22:18.536Z
debug:  custom=Test Object Log Message, error=false, level=debug, message=Debug exented message, timestamp=2014-03-14T14:22:18.537Z
info:  anything=This is metadata, level=info, message=Test Log Message, timestamp=2014-03-14T14:22:18.538Z

Note that into the client terminal you see only the info message whereas into the server terminal you see all messages because the server has a customized level of the Console Transport.

For more information please refer to winston and axon documentations.

Run Tests

Like other Transport plugins, all of the winston-axon tests are written in vows, and designed to be run with npm.

$ npm test
npm loves you