5.1.1 • Published 1 year ago

winston-mongodb v5.1.1

Weekly downloads
22,499
License
MIT
Repository
github
Last release
1 year ago

winston

A MongoDB transport for winston.

Current version supports only mongodb driver version 3.x and winston 3.x. If you want to use winston-mongodb with mongodb version 1.4.x use winston-mongodb <1.x. For mongodb 2.x use winston-mongodb <3.x.

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.

Usage

  var winston = require('winston');

  /**
   * Requiring `winston-mongodb` will expose
   * `winston.transports.MongoDB`
   */
  require('winston-mongodb');

  winston.add(new winston.transports.MongoDB(options));

The MongoDB transport takes the following options. 'db' is required:

  • level: Level of messages that this transport should log, defaults to 'info'.
  • silent: Boolean flag indicating whether to suppress output, defaults to false.
  • db: MongoDB connection uri, pre-connected MongoClient object or promise which resolves to a pre-connected MongoClient object.
  • dbName: The database name to connect to, defaults to DB name based on connection URI if not provided, ignored if using a pre-connected mongoose connection.
  • options: MongoDB connection parameters (optional, defaults to {poolSize: 2, autoReconnect: true, useNewUrlParser: true}).
  • collection: The name of the collection you want to store log messages in, defaults to 'log'.
  • storeHost: Boolean indicating if you want to store machine hostname in logs entry, if set to true it populates MongoDB entry with 'hostname' field, which stores os.hostname() value.
  • label: Label stored with entry object if defined.
  • name: Transport instance identifier. Useful if you need to create multiple MongoDB transports.
  • capped: In case this property is true, winston-mongodb will try to create new log collection as capped, defaults to false.
  • cappedSize: Size of logs capped collection in bytes, defaults to 10000000.
  • cappedMax: Size of logs capped collection in number of documents.
  • tryReconnect: Will try to reconnect to the database in case of fail during initialization. Works only if db is a string. Defaults to false.
  • decolorize: Will remove color attributes from the log entry message, defaults to false.
  • leaveConnectionOpen: Will leave MongoClient connected after transport shut down.
  • metaKey: Configure which key is used to store metadata in the logged info object. Defaults to 'metadata' to remain compatible with the metadata format
  • expireAfterSeconds: Seconds before the entry is removed. Works only if capped is not set.

Metadata: Logged as a native JSON object in 'meta' property.

Logging unhandled exceptions: For logging unhandled exceptions specify winston-mongodb as handleExceptions logger according to winston documentation.

Querying and streaming logs

Besides supporting the main options from winston, this transport supports the following extra options:

  • includeIds: Whether the returned logs should include the _id attribute settled by mongodb, defaults to false.

Installation

  $ npm install winston
  $ npm install winston-mongodb

Changelog

Author: Charlie Robbins

Contributors: Yurij Mikhalevich, Kendrick Taylor, Yosef Dinerstein, Steve Dalby

@back4app/back4apppac_loggerhoserver-frameworkers_flowtagbackendapi.logger2@ciondigital/loggerforge-nodejs-logs@ciondigital/cion-platformraslack@infinitebrahmanuniverse/nolb-winslipslide-commonsyngrisi@everything-registry/sub-chunk-3150@kodermax/orange-coresielse-logedusafety-apistk-winstonerrorboard.jsdennis0034docparse-logger@dhealthdapps/backendrsocketrrloggersbblogsosick-boilerplatedcrawlerskoolaideeasy-winston-loggerbytehappens-logging-winston@baaldev/loggerceo-loggercm2-worker@clicbrics/blockchain@clicbrics/comcommonutilitiescommon-utility@coobo/spendfy-loggercornerstonelabs-semantic-logging@coya/loggerclasio-util@blueprod/logger@bnasmart/common@antiers/product-package@armco/node-starter-kitcustom-winston-logger@datasinfo/userms@datastrata/ds-logger@dazejs/framework@dk.escale/sdkcurrentcms@dreesq/serpent@dotcom-gosahi/centralized-exception-and-error-handling@adhiman24/aembazery-public-apiflight-search-commonsup-logsfernet-logappmech-logger@tiledesk/tiledesk-server@tc-modules/logger@tc-packages/logger@the-connective/loggeracrb-node-coreall-modulesab-loggeraxxer@1onlinesolution/dws-log@1onlinesolution/dws-coreteambottimesheet-testwrepackagegrade-apiharu-nodejs-utiltockglobalbot-utilsutility-beaksjust-loggitxshan-envwinston-customise-loggerworkai-igloowinston_mongo_loggerw-tiny-loggericarus-graphqlwearbuddy_common_jsiglooihealth-winstonloghelio-api-boilerplatevidly-gurwinderheadlight-utillog-rhythm@lmos/logger@meteor-labs/truck-logger@memmcode/common@mdazad/common-utils@hiregeeb/commonletcome-envleafcase-web-applicationmetas-detectmhp.vinfo.web.common@jamesjnadeau/igloo
5.1.1

1 year ago

5.1.0

2 years ago

5.0.7

3 years ago

5.0.6

3 years ago

5.0.5

4 years ago

5.0.4

4 years ago

5.0.3

4 years ago

5.0.2

4 years ago

5.0.1

4 years ago

5.0.0

5 years ago

4.0.9

5 years ago

4.0.8

5 years ago

4.0.7

5 years ago

4.0.6

5 years ago

4.0.5

5 years ago

4.0.4

5 years ago

4.0.3

6 years ago

4.0.2

6 years ago

4.0.1

6 years ago

4.0.0

6 years ago

4.0.0-rc1

6 years ago

3.0.2

6 years ago

4.0.0-rc0

6 years ago

3.0.1

7 years ago

3.0.0

7 years ago

2.0.10

7 years ago

2.0.9

7 years ago

2.0.8

7 years ago

2.0.7

7 years ago

2.0.6

7 years ago

2.0.5

7 years ago

2.0.4

7 years ago

2.0.3

7 years ago

2.0.2

7 years ago

1.6.6

7 years ago

2.0.1

7 years ago

1.6.5

7 years ago

2.0.0

7 years ago

1.6.4

7 years ago

1.6.3

7 years ago

1.6.2

7 years ago

1.6.1

8 years ago

1.6.0

8 years ago

1.5.0

8 years ago

1.4.0

8 years ago

1.3.0

8 years ago

1.2.0

9 years ago

1.1.2

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.5.3

9 years ago

0.5.2

10 years ago

0.5.1

10 years ago

0.5.0

10 years ago

0.4.7

10 years ago

0.4.6

10 years ago

0.4.5

10 years ago

0.4.3

10 years ago

0.4.2

11 years ago

0.4.1

11 years ago

0.4.0

12 years ago

0.3.4

12 years ago

0.3.3

12 years ago

0.3.2

13 years ago

0.3.1

13 years ago

0.3.0

13 years ago

0.2.0

13 years ago