winston-loggly-bulk vs loggly-jslogger
Logging Libraries for JavaScript Comparison
1 Year
winston-loggly-bulkloggly-jsloggerSimilar Packages:
What's Logging Libraries for JavaScript?

Both loggly-jslogger and winston-loggly-bulk are JavaScript libraries designed for logging purposes, specifically integrating with Loggly, a cloud-based log management service. loggly-jslogger is a lightweight library focused on client-side logging, allowing developers to send logs directly from the browser to Loggly. In contrast, winston-loggly-bulk is a transport for the popular Winston logging library, enabling server-side logging with bulk log sending capabilities, making it suitable for Node.js applications. These libraries help developers monitor application behavior and troubleshoot issues by capturing and sending log data to Loggly for analysis and visualization.

Package Weekly Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
winston-loggly-bulk34,2223822.6 kB94 months agoMIT
loggly-jslogger14,0377943.6 kB17-MIT
Feature Comparison: winston-loggly-bulk vs loggly-jslogger

Logging Methodology

  • winston-loggly-bulk:

    winston-loggly-bulk leverages the Winston logging framework's capabilities, allowing for structured logging with various transports. It supports bulk sending of logs, which optimizes network usage and improves performance when dealing with high log volumes, making it suitable for server-side applications.

  • loggly-jslogger:

    loggly-jslogger provides a straightforward logging methodology that allows developers to log messages directly from the client-side. It supports different log levels (e.g., info, warn, error) and can capture user interactions, making it easy to track issues in real-time as they occur in the browser.

Integration

  • winston-loggly-bulk:

    winston-loggly-bulk integrates seamlessly with the Winston logging framework, allowing developers to utilize Winston's extensive features such as log formatting, filtering, and multiple transport options. This makes it a powerful choice for applications that already use Winston for logging.

  • loggly-jslogger:

    loggly-jslogger is designed specifically for integration with Loggly, providing a simple API to send logs directly to the Loggly service. It requires minimal setup and is easy to implement in any web application, making it a quick solution for client-side logging needs.

Performance

  • winston-loggly-bulk:

    winston-loggly-bulk is designed to handle large volumes of logs efficiently by sending them in bulk. This reduces the number of network requests and improves overall performance, especially in high-load server environments.

  • loggly-jslogger:

    loggly-jslogger is optimized for performance in client-side environments, ensuring that log messages are sent efficiently without significantly impacting the user experience. It uses asynchronous calls to send logs, minimizing delays in the application's responsiveness.

Error Handling

  • winston-loggly-bulk:

    winston-loggly-bulk allows for comprehensive error logging on the server side, capturing unhandled exceptions and logging them to Loggly. This helps developers monitor server health and troubleshoot issues effectively.

  • loggly-jslogger:

    loggly-jslogger includes built-in error handling capabilities, allowing developers to capture and log JavaScript errors that occur in the browser. This feature is crucial for debugging client-side issues and improving application stability.

Configuration Flexibility

  • winston-loggly-bulk:

    winston-loggly-bulk provides extensive configuration options through Winston, enabling developers to customize log formats, levels, and transports. This flexibility is beneficial for applications with complex logging requirements.

  • loggly-jslogger:

    loggly-jslogger offers a simple configuration setup, allowing developers to easily customize log levels and other parameters. This flexibility makes it easy to adapt the logging behavior to different environments (e.g., development vs. production).

How to Choose: winston-loggly-bulk vs loggly-jslogger
  • winston-loggly-bulk:

    Choose winston-loggly-bulk if you are working with a Node.js application and require a robust logging solution that integrates with the Winston logging framework. This package is suitable for applications that generate a large volume of logs and need to send them in bulk to Loggly for efficient processing.

  • loggly-jslogger:

    Choose loggly-jslogger if you need a simple and lightweight solution for client-side logging directly from the browser. It is ideal for front-end applications where you want to capture user interactions and errors without the overhead of a full logging framework.

README for winston-loggly-bulk

winston-loggly-bulk

A Loggly transport for winston.

Version npmnpm Downloads

NPM

A client implementation for Loggly in node.js. Check out Loggly's Node logging documentation for more.

Usage

  var winston = require('winston');

  //
  // Requiring `winston-loggly-bulk` will expose
  // `winston.transports.Loggly`
  //
  var {Loggly} = require('winston-loggly-bulk');

  winston.add(new Loggly({options}));

The Loggly transport is based on Nodejitsu's node-loggly implementation of the Loggly API. If you haven't heard of Loggly before, you should probably read their value proposition. The Loggly transport takes the following options.

  • subdomain: The subdomain of your Loggly account. [required]
  • token: The access token (previously inputToken) [required]
  • auth: The authentication information for your Loggly account.
  • json: If true, messages will be sent to Loggly as JSON.
  • tags: An array of tags to send to loggly.
  • isBulk: If true, sends messages using bulk url
  • stripColors: Strip color codes from the logs before sending
  • bufferOptions: Buffer options has two configurations.
    • size: Number of logs to be buffered.
    • retriesInMilliSeconds: Time in milliseconds to retry sending buffered logs.
  • timestamp: If false, library will not include timestamp in log events.
    • Note: Library includes timestamp by default when we do not set timestamp option.
  • networkErrorsOnConsole: The library keep track of different network errors and can log them to console. By default, logging errors on console is disabled and can be enabled easily by setting this parameter's value to true. If true, all the network errors will be logged to console.

Sample Working Code Snippet

var winston  = require('winston');
var { Loggly } = require('winston-loggly-bulk');

winston.add(new Loggly({
    token: "TOKEN",
    subdomain: "SUBDOMAIN",
    tags: ["Winston-NodeJS"],
    json: true
}));

winston.log('info', "Hello World from Node.js!");

Buffer Support

This library has buffer support during temporary network outage. User can configure size of buffer (no. of logs to be stored during network outage).

Add these below configuration in code snippet to override the default values of buffer option size and retriesInMilliSeconds.

bufferOptions: {
  size: 1000,
  retriesInMilliSeconds: 60 * 1000
}  
  • Note: The default value of buffer size and retries in milliseconds are 500 and 30000 (30 seconds) respectively.

Flush logs and exit

Our library uses ajax requests to send logs to Loggly, and as ajax requests take time to complete, logs can be lost when process.exit() is called because it forces an immediate exit. To exit gracefully and ensure that the last logs get to Loggly, we created a function called flushLogsAndExit(). It waits for 10 seconds and then calls process.exit() itself. This allows enough time for the logs to be sent to Loggly.

Here is an example of how to use the method:

var winston = require('winston');
var { flushLogsAndExit } = require('winston-loggly-bulk');

winston.log("info", "Hello World from Node.js!");
flushLogsAndExit();

Motivation

tldr;?: To break the winston codebase into small modules that work together.

The winston codebase has been growing significantly with contributions and other logging transports. This is awesome. However, taking a ton of additional dependencies just to do something simple like logging to the Console and a File is overkill.

Installation

  npm install winston-loggly-bulk

Note: If you are using npm version 2, please run the below command:

  npm install winston-loggly-bulk winston

Run Tests

Written in Jest. Testing that log events are correctly passed on.

  npm test

Author: Charlie Robbins

Contributors: Loggly, Shweta Jain,