Node.js Logging

You can send your Node.js logs using our winston-loggly-bulk package. It sends logs directly from your application to Loggly using the HTTP/S Event API. For alternatives, please see the Advanced Options section.

Node.js Logging Setup

  1. Install the winston-loggly-bulk package
  2. Install the loggly-winston-bulk package using NPM or from Github

    npm install winston
    npm install winston-loggly-bulk

  1. Configure loggly-winston-bulk
  2. Paste the following code to create a Loggly client.

    var winston  = require('winston');
    require('winston-loggly-bulk');
     
     winston.add(winston.transports.Loggly, {
        inputToken: "TOKEN",
        subdomain: "SUBDOMAIN",
        tags: ["Winston-NodeJS"],
        json:true
    });
    
    winston.log('info',"Hello World from Node.js!");
    

    Replace:

    • TOKEN: your customer token from the source setup page
    • SUBDOMAIN: the subdomain of your Loggly account

  1. Send Test Events
  2. Run your application to send test events to Loggly.

  1. Verify Events
  2. Search Loggly for events with the Winston-NodeJS tag over the past 20 minutes. It may take a few minutes to index the event. If it doesn’t work, see the troubleshooting section below.

    tag:Winston-NodeJS

    Click on one of the logs to show a list of JSON fields (see screenshot below). If you don’t see them, please check that you are using one of our automatically parsed formats.

    NodeJs-Screenshot

Advanced Node.js Logging Options

  • Package Docs – Describes how to send JSON objects, arrays, use tags, and more
  • node-Loggly-bulk – Use the node-loggly-bulk library to send node.js logs
  • bunyan-loggly – Use the bunyan library which has a wrapper for node-loggly
  • log4js – Use the log4js library which has a wrapper for node-loggly
  • HTTP/S Bulk Endpoint – Send up to 5MB batches of logs over HTTP/S for higher performance
  • Loggly Libraries Catalog – New libraries are added to our catalog
  • Search or post your own Node.js logging or custom logging questions in the community forum.

Troubleshooting Node.js Logs

If you don’t see any data show up in the verification step, then check for these common problems.

    Check winston-loggly-bulk:

    • Wait a few minutes in case indexing needs to catch up
    • See our HTTP Troubleshooting Guide to verify HTTP events are being sent to Loggly.

    Still Not Working?

    • Search or post your own questions on Node.js logging levels, file transport, log messages, and more in the community forum.
Thanks for the feedback! We'll use it to improve our support documentation.


Top