winston-mongodb-wt
v1.1.2
Published
winston-mongodb for worktile
Downloads
17
Readme
winston-mongodb for wt
参考:https://github.com/winstonjs/winston-mongodb
- 支持log和error 日志的分开存储
- 支持错误信息 pub 到 redis中
安装
执行 npm i winston-mongodb-wt --save
Usage
var winston = require('winston');
/**
* Requiring `winston-mongodb-wt` will expose
* `winston.transports.MongoDB`
*/
require('winston-mongodb-wt').MongoDB;
winston.add(winston.transports.MongoDB, options);
options 参数说明
- level: 错误级别, 默认 'info'.
- db: mongodb 连接字符串.
- collection:默认日志表的集合,默认为 log
- errorCollection:错误日志表存储的集合,默认和collection相同
- options: MongoDB connection parameters (optional, defaults to {db: {native_parser: true}, server: {poolSize: 2, socketOptions: {autoReconnect: true}}}).
- 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: 存储在Log表中,可以作为 app name 区分日志.
- name: Transport instance identifier. Useful if you need to create multiple MongoDB transports.
- redis,level为error pub到 redis 中去,格式为:
redis:{
port:xxx,
host:xxx,
password:xxx,
options:xxx
channel:xxx,//默认logError
}