loggly vs loggly-jslogger vs winston-loggly-bulk
日志记录库
logglyloggly-jsloggerwinston-loggly-bulk类似的npm包:

日志记录库

这些库用于将日志信息发送到 Loggly,这是一个基于云的日志管理服务。它们允许开发者在应用程序中轻松集成日志记录功能,以便于监控和调试。通过这些库,开发者可以将应用程序的运行状态、错误信息和其他重要事件记录到 Loggly,从而实现集中化的日志管理和分析。

npm下载趋势

3 年

GitHub Stars 排名

统计详情

npm包名称
下载量
Stars
大小
Issues
发布时间
License
loggly0233-2210 年前MIT
loggly-jslogger07943.6 kB17-MIT
winston-loggly-bulk03721.3 kB89 个月前MIT

功能对比: loggly vs loggly-jslogger vs winston-loggly-bulk

集成方式

  • loggly:

    Loggly 提供了直接与其 API 交互的功能,适合需要简单集成的项目。

  • loggly-jslogger:

    loggly-jslogger 是专为浏览器设计的,能够自动捕获和发送错误信息,适合前端开发。

  • winston-loggly-bulk:

    winston-loggly-bulk 是 Winston 的一个传输插件,支持批量发送日志,适合需要高效日志管理的后端服务。

错误捕获能力

  • loggly:

    Loggly 本身不提供错误捕获功能,需要手动记录错误信息。

  • loggly-jslogger:

    loggly-jslogger 可以自动捕获 JavaScript 错误并将其发送到 Loggly,简化了错误日志记录。

  • winston-loggly-bulk:

    winston-loggly-bulk 依赖于 Winston 的错误处理机制,能够灵活配置错误捕获。

适用场景

  • loggly:

    适合简单的日志记录需求,尤其是在小型项目中。

  • loggly-jslogger:

    适合需要在浏览器中记录用户操作和错误的前端应用。

  • winston-loggly-bulk:

    适合使用 Winston 的大型后端应用,能够处理复杂的日志记录和格式化需求。

性能

  • loggly:

    性能较好,但在高频率日志记录时可能会受到 API 限制。

  • loggly-jslogger:

    在前端应用中性能良好,能够快速捕获和发送日志。

  • winston-loggly-bulk:

    通过批量发送日志提高性能,适合高负载的后端服务。

学习曲线

  • loggly:

    学习曲线较平缓,易于上手,适合初学者。

  • loggly-jslogger:

    相对简单,适合前端开发者快速集成。

  • winston-loggly-bulk:

    需要对 Winston 有一定了解,学习曲线稍陡,但功能强大。

如何选择: loggly vs loggly-jslogger vs winston-loggly-bulk

  • loggly:

    选择 Loggly 如果你需要一个简单的客户端库来直接与 Loggly API 交互,适合小型项目或简单的日志记录需求。

  • loggly-jslogger:

    选择 loggly-jslogger 如果你需要在浏览器中记录日志并希望能够自动捕获异常和错误信息,适合前端应用程序的日志记录。

  • winston-loggly-bulk:

    选择 winston-loggly-bulk 如果你已经在使用 Winston 作为日志记录库,并希望将日志批量发送到 Loggly,适合需要复杂日志管理和格式化的后端应用程序。

loggly的README

node-loggly

Version npmnpm DownloadsBuild StatusDependencies

NPM

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

Usage

The node-loggly library is compliant with the Loggly API. Using node-loggly is easy for a variety of scenarios: logging, working with devices and inputs, searching, and facet searching.

Getting Started

Before we can do anything with Loggly, we have to create a client with valid credentials. We will authenticate for you automatically:

  var loggly = require('loggly');

  var client = loggly.createClient({
    token: "your-really-long-input-token",
    subdomain: "your-subdomain",
    auth: {
      username: "your-username",
      password: "your-password"
    },
    //
    // Optional: Tag to send with EVERY log message
    //
    tags: ['global-tag']
  });

Logging

There are two ways to send log information to Loggly via node-loggly. The first is to simply call client.log with an appropriate input token:

  client.log('127.0.0.1 - Theres no place like home', function (err, result) {
    // Do something once you've logged
  });

Note that the callback in the above example is optional, if you prefer the 'fire and forget' method of logging:

  client.log('127.0.0.1 - Theres no place like home');

Logging with Tags

If you're using Loggly's tags functionality, simply include an array of tags as the second argument to the log method:

  client.log('127.0.0.1 - Theres no place like home', [ 'dorothy' ], function (err, result) {
    // Do something once you've logged
  });

note Tags passed into the log function will be merged with any global tags you may have defined.

Logging Shallow JSON Objects as a String

In addition to logging pure strings it is also possible to pass shallow JSON object literals (i.e. no nested objects) to client.log(..) or input.log(..) methods, which will get converted into the Loggly recommended string representation. So

  var source = {
    foo: 1,
    bar: 2,
    buzz: 3
  };

  input.log(source);

will be logged as:

  foo=1,bar=2,buzz=3

Logging JSON Objects

It is also possible to log complex objects using the new JSON capabilities of Loggly. To enable JSON functionality in the client simply add 'json: true' to the configuration:

  var config = {
    subdomain: "your-subdomain",
    auth: {
      username: "your-username",
      password: "your-password"
    },
    json: true
  };

When the json flag is enabled, objects will be converted to JSON using JSON.stringify before being transmitted to Loggly. So

  var source = {
    foo: 1,
    bar: 2,
    buzz: {
      sheep: 'jumped',
      times: 10
    }
  };

  input.log(source);

will be logged as:

  { "foo": 1, "bar": 2, "buzz": {"sheep": "jumped", "times": 10 }}

Logging arrays

It is possible to send arrays, which will result in one single request to Loggly.

  input.log([ {iam:'number 1'}, {iam:'number 2'} ])

Searching

Searching with node-loggly is easy. All you have to do is use the search() method defined on each Loggly client:

  var util = require('util');

  client.search('404', function (err, results) {
    // Inspect the result set
    console.dir(results.events);
  });

The search() method can also take an Object parameter that allows you to set additional search parameters such as: rows, from, until, etc.

  var util = require('util');

  client.search({ query: '404', rows: 10 })
    .run(function (err, results) {
      // Inspect the result set
      console.dir(results.events);
    });

See the Loggly search guide for more details on how to effectively search through your Loggly logs.

Installation

Installing npm (node package manager)

  $ curl http://npmjs.org/install.sh | sh

Installing node-loggly

  $ npm install loggly

Run Tests

All of the node-loggly tests are written in vows, and cover all of the use cases described above. You will need to add your Loggly username, password, subdomain, and a two test inputs to test/data/test-config.json before running tests. When configuring the test inputs on Loggly, the first test input should be named 'test' using the HTTP service. The second input should be name 'test_json' using the HTTP service with the JSON logging option enabled:

  {
    "token": "your-really-long-token-you-got-when-you-created-an-http-input",
    "subdomain": "your-subdomain",
    "auth": {
      "username": "your-username",
      "password": "your-password"
    }
  }

Once you have valid Loggly credentials you can run tests with vows:

  $ npm test

Author: Charlie Robbins

Contributors: Marak Squires, hij1nx, Kord Campbell, Erik Hedenström,