Configuring centralized logging from Node.js apps

Papertrail can accept logs from any Node.js app using a regular text log file or the libraries winston or bunyan.

If the Node.js app is running on Heroku, try the Heroku setup instead.

Send log file with remote_syslog2

Have Node log to a file, then transmit the log file to Papertrail using remote_syslog2.

To make Node log to a file, either redirect its output or use the fs module. For example, to redirect stdout to myapp.log, start the daemon with:

$ nohup node myapp.js > myapp.log &

Send events from Node.js

Use the winston Papertrail transport to asynchronously transmit events from Node.js. See the transport README.

To log unhandled exceptions, see the winston documentation.

node-bunyan users can use the node-bunyan-syslog stream.