Node-restify: Add support for Winston Logging

Created on 14 Dec 2012  路  6Comments  路  Source: restify/node-restify

Bunyan logging is extremely limited whereas Winston has support for Loggly and several other transports along with much more flexibility. Boxing restify into Bunyan is creating a lot of extra work for those of us who need more control over how their log data is handled and where it goes.

Most helpful comment

Here is an example of a Bunyan stream to Winston and an example using that with a Restify server: https://github.com/trentm/node-bunyan-winston/blob/master/restify-winston.js#L18-L80

@danhstevens Would you be able to give that snippet a try to see if it works for you? I'm not experienced with Winston to know if there are demons in this shim. If this works well, I'll turn this demo repo into a real 'bunyan-winston' npm module to make this convenient.

Also, for my curiosity, I'd love to know what (in addition to the Loggly transport that you've mentioned) in Winston are particular flexibilities and features you value in your Winston usage.

Cheers.

All 6 comments

What exactly is it you want extra? The bunyan support in restify is totally opt-in - you should be able to use winston, or any other logger just fine?

The internals of restify (router, response, server, etc) expect a Bunyan logger in order to log trace information and even warnings. Calls to log.trace() etc aren't compatible with Winston calls. There's no good way to see what's going on inside restify without using Bunyan logging which doesn't have much flexibility.

Web servers like Apache include the capability to create custom loggers for their internals and so my mindset is geared towards having a similar level of flexibility which Bunyan doesn't afford. We can and have plugged in Winston logging where we can but aside from creating our own fork the internals of Restify are locked into Bunyan.

Just one mans opinion / vote to use a more capable logger for Restify.

Well, I know @trentm cares deeply about bunyan being best of class - but I wonder if it's possible to just setup a bunyan stream to winston? If what you want are the restify internals? And yeah, I know elsewhere there's standard logging APIs (i.e., SLF4J et al), but node has no such thing so you kind of need somebody to shim.

Here is an example of a Bunyan stream to Winston and an example using that with a Restify server: https://github.com/trentm/node-bunyan-winston/blob/master/restify-winston.js#L18-L80

@danhstevens Would you be able to give that snippet a try to see if it works for you? I'm not experienced with Winston to know if there are demons in this shim. If this works well, I'll turn this demo repo into a real 'bunyan-winston' npm module to make this convenient.

Also, for my curiosity, I'd love to know what (in addition to the Loggly transport that you've mentioned) in Winston are particular flexibilities and features you value in your Winston usage.

Cheers.

Note on the link above, see https://github.com/trentm/node-bunyan-winston/blob/master/README.md#winston-logging-restify-winstonjs for what it looks like for me.

Thanks @trentm!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

augustovictor picture augustovictor  路  4Comments

0v3rst33r picture 0v3rst33r  路  6Comments

nodesocket picture nodesocket  路  4Comments

talha-asad picture talha-asad  路  6Comments

mongris picture mongris  路  5Comments