loggly-jslogger vs winston-loggly-bulk
Logging Libraries for JavaScript
loggly-jsloggerwinston-loggly-bulkSimilar Packages:

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.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
loggly-jslogger08043.6 kB17-MIT
winston-loggly-bulk03721.3 kB83 months agoMIT

Feature Comparison: loggly-jslogger vs winston-loggly-bulk

Logging Methodology

  • 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.

  • 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.

Integration

  • 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.

  • 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.

Performance

  • 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.

  • 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.

Error Handling

  • 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.

  • 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.

Configuration Flexibility

  • 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).

  • 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.

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

  • 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.

  • 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.

README for loggly-jslogger

loggly-jslogger

Client-side (browser) logger to send Javascript logs from any website to Loggly. Check out Loggly’s Javascript logging documentation to learn more.

Installation

Insert the following code into your webpage, replacing your-customer-token with the key defined in the Source Setup -> Customer Tokens page:

<script type="text/javascript" src="https://cloudfront.loggly.com/js/loggly.tracker-2.2.4.min.js" async></script>
<script>
  var _LTracker = _LTracker || [];
  _LTracker.push({
    'logglyKey': 'your-customer-token',
    'sendConsoleErrors': true,
    'tag': 'javascript-logs'
  });
</script>

To get early access to the most recent updates to the tracker, use the script https://cloudfront.loggly.com/js/loggly.tracker-latest.min.js. This is not recommended in a production environment as it may include breaking changes.

Usage

Logging text:

_LTracker.push('my tracking string');

Logging JSON:

_LTracker.push({
  'text': 'my tracking string',
  'aList': [9, 2, 5],
  'anObject': {
    'id': 1,
    'value': 'foobar'
  }
});

Customization

Separate logging instance:

var myBetterLogger = new LogglyTracker();
myBetterLogger.push({'logglyKey': 'your-customer-token' });  // push a loggly key to initialize

Send Console Errors to Loggly

Keep the sendConsoleErrors value to true to send all unhandled errors to Loggly with detailed information, including error message, URL, line number and column number.

Send Tags to Loggly

Send your custom tags to Loggly by setting the tag property.

_LTracker.push({
  'logglyKey': 'your-customer-token',
  'sendConsoleErrors' : true,
  'tag' : 'tag1,tag2'
});

Special Characters Support

Set the useUtfEncoding value to true to prevent special characters from showing as odd or unusual characters in Loggly Search. Special characters will be easier to read and understand in your log events.

See the usage below:

_LTracker.push({
  'logglyKey': 'your-customer-token',
  'sendConsoleErrors' : true,
  'tag' : 'javascript-logs',
  'useUtfEncoding': true
});

Setup Proxy for Ad blockers

If the script or its requests are blocked by ad blockers, you can proxy requests from your own domain. To do this, perform following steps

Set useProxyDomain property to true

_LTracker.push({
  'logglyKey': 'your-customer-token',
  'sendConsoleErrors' : true,
  'tag' : 'javascript-logs',
  'useDomainProxy' : true
});

Use the following configuration on your server to forward the requests to Loggly

#Proxy to Loggly
location /loggly/ {
    rewrite ^/loggly/(.*)$ /$1 break;  # remove the '/loggly' part from the path, leaving /inputs/xxxxxxxx-xxxx-.../tag/xxx
    proxy_set_header Host logs-01.loggly.com;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_pass http://logs-01.loggly.com;
}

Build Production Version

Run npm run build to build production version. The output is saved in folder dist.

Run tests

In your web browser open file jasminetest/TrackerSpecRunner.html.