NOTE
StrongLoop Arc and slc are no longer under active development, and will soon be deprecated. Arc's features are being included in the IBM API Connect Developer Toolkit: Please use it instead.
Skip to end of metadata
Go to start of metadata

Using Winston

Winston is one of the most popular Node logging libraries.  It is simple and supports logging to multiple transports.

Install Winston:

Use Winston:

Transports

Winston comes with file- and console-based transports, but many others are available on npmjs.org.  For example:

 

Winston also has a Splunk transport:

For information on additional transports and other options, see https://github.com/flatiron/winston.

Using Bunyan

Bunyan provides structured machine-readable logging.

Install Bunyan:

Use Bunyan; for example:

The above code would produce the output such as the following:

Child loggers

Bunyan enables you to create separate child loggers for each sub-component of your application.

For example, in Express you might use a child logger per request.

This would produce a log such as the following:

  • No labels