项目作者: mwittig

项目描述 :
A logstash transport for winston based on node-lumberjack-protocol, a lumberjack protocol implementation for Node.js
高级语言: JavaScript
项目地址: git://github.com/mwittig/winston-lumberjack.git
创建时间: 2015-07-09T16:40:33Z
项目社区:https://github.com/mwittig/winston-lumberjack

开源协议:MIT License

下载


winston-lumberjack

Build Status
Greenkeeper badge

A logstash transport for winston based on
node-lumberjack-protocol, a
lumberjack protocol implementation for Node.js. It allows for sending encrypted logs from your node.js app to
your logstash server instance.

Usage

Node

  1. var winston = require('winston');
  2. // Simply requiring winston-lumberjack will assign winston.transports.Lumberjack
  3. require('winston-lumberjack');
  4. winston.add(winston.transports.Lumberjack, {
  5. "timestamp": true,
  6. "level": "debug",
  7. "serverAddress": {
  8. "host": "localhost",
  9. "port": 5000
  10. },
  11. "sslCrt": "./logstash-forwarder.crt"
  12. });
  13. winston.log('debug', 'Now my debug messages are written to logstash!');

Lumberjack Configuration

  • sslCert (optional)

    Filename of the trusted CA certificate which has signed the logstash server certificate. If this is omitted several
    well known “root” CAs will be used. These are used to authorize connections.

  • serverAddress

    An object to specify the host and port of the logstash server. Additionally, all options supported by
    tls.connect() may be provided. If the ca
    property is the content of the file referenced by the sslCert property (if provided) will be set as ca.

    “serverAddress”: {

    1. "host": "localhost",
    2. "port": 5000

    }

  • level (optional)

    Level of messages this transport should log. Defaults to ‘info’.

  • timestamp (optional)

    Boolean flag indicating if log messages shall include a timestamp. Defaults to false.

  • clientOptions (optional)

    An object with additional configuration option passed on to the lumberjack protocol stack:

    • windowSize - the windowSize to send to the receiver. Defaults to 1000. See Caveats section of
      node-lumberjack-protocol README for details.

    • maxQueueSize - the maximum number of messages to queue while disconnected.
      If this limit is hit, all messages in the queue will be filtered with
      allowDrop(data). Only messages which this function returns true for will be
      removed from the queue. If there are still too many messages in the queue at this point
      the the oldest messages will be dropped. Defaults to 500.

    • allowDrop(data) - this will be called when deciding which messages to drop.
      By dropping lower priority messages (info and debug level messages, for example) you can
      increase the chances of higher priority messages getting through when the Client is
      having connection issues, or if the receiver goes down for a short period of time.
      This function is used both to drop messages from the queue while disconnected, and to drop
      messages if the receiver is taking too long to acknowledge messages.

      Note that this function will be called on all messages in the queue every time the queue grows
      too large - if this function does not return true for any messages, then it could be called
      for every message in the queue every time a message is queued.

    • options.reconnect - time, in ms, to wait between reconnect attempts. Defaults to 3 seconds.

License

Copyright (c) 2015-2018, Marcus Wittig
All rights reserved.

MIT