You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*__collection__: The name of the collection you want to store log messages in,
44
-
defaults to 'log'.
45
-
*__storeHost:__ Boolean indicating if you want to store machine hostname in
46
-
logs entry, if set to true it populates MongoDB entry with 'hostname' field,
47
-
which stores os.hostname() value.
48
-
*__label:__ Label stored with entry object if defined.
49
-
*__name:__ Transport instance identifier. Useful if you need to create multiple
50
-
MongoDB transports.
51
-
*__capped:__ In case this property is true, winston-mongodb will try to create
52
-
new log collection as capped, defaults to false.
53
-
*__cappedSize:__ Size of logs capped collection in bytes, defaults to 10000000.
54
-
*__cappedMax:__ Size of logs capped collection in number of documents.
55
-
*__tryReconnect:__ Will try to reconnect to the database in case of fail during
56
-
initialization. Works only if __db__ is a string. Defaults to false.
57
-
*__decolorize:__ Will remove color attributes from the log entry message,
58
-
defaults to false.
59
-
*__leaveConnectionOpen:__ Will leave MongoClient connected after transport shut down.
60
-
*__metaKey:__ Configure which key is used to store metadata in the logged info object.
61
-
Defaults to `'metadata'` to remain compatible with the [metadata format](https://github.com/winstonjs/logform/blob/master/examples/metadata.js)
62
-
*__expireAfterSeconds:__ Seconds before the entry is removed. Works only if __capped__ is not set.
63
-
64
-
*Metadata:* Logged as a native JSON object in 'meta' property.
54
+
The MongoDB transport takes the following options. Only option `db` is required:
| db |**REQUIRED**. MongoDB connection uri, pre-connected `MongoClient` object or promise which resolves to a pre-connected `MongoClient` object. |
59
+
| dbname | The database name to connect to, defaults to DB name based on connection URI if not provided, ignored if using a pre-connected connection. |
| collection | The name of the collection you want to store log messages in.<br/>Defaults to `log`. |
62
+
| level | Level of messages that this transport should log.<br/>Defaults to `info`. |
63
+
| silent | Boolean flag indicating whether to suppress output.<br/>Defaults to `false`. |
64
+
| 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. |
65
+
| label | If set to true, then label attribute content will be stored in `label` field, if detected in meta-data. |
66
+
| name | Transport instance identifier. Useful if you need to create multiple MongoDB transports. |
67
+
| capped | In case this property is true, winston-mongodb will try to create new log collection as capped.<br/>Defaults to `false`. |
68
+
| cappedSize | Size of logs capped collection in bytes.<br/>Defaults to 10,000,000. |
69
+
| cappedMax | Size of logs capped collection in number of documents. |
70
+
| tryReconnect | Will try to reconnect to the database in case of fail during initialization. Works only if __db__ is a string.<br/>Defaults to `false`. |
71
+
| decolorize | Will remove color attributes from the log entry message.<br/>Defaults to `false`. |
72
+
| leaveConnectionOpen| Will leave MongoClient connected after transport shuts down. |
73
+
| metaKey | Configure name of the field which is used to store metadata in the logged info object.<br/>Defaults to `metadata` to remain compatible with the [metadata format](https://github.com/winstonjs/logform/blob/master/examples/metadata.js)|
74
+
| expireAfterSeconds |Seconds before the entry is removed. Works only if __capped__ is not set. |
65
75
66
76
*Logging unhandled exceptions:* For logging unhandled exceptions specify
67
77
winston-mongodb as `handleExceptions` logger according to winston documentation.
0 commit comments