Winstonjs没有记录任何例外情况?

时间:2015-07-16 08:31:37

标签: node.js koa winston

我正在使用Winston在我的Koajs应用程序中记录信息。我已尝试使用默认记录器来记录未处理的异常,方法是遵循文档here

但由于某些原因,只有从我的index.js文件中抛出未处理的异常时才会记录它们。从其中一条路线抛出异常不会导致winston记录异常?

编辑:

以下是代码:

let winston = require('winston');

let cassandra = require('cassandra-driver');
let winstonCassandra = require('../lib/winston_cassandra/index');
let config = require("../config/config");

let authProvider = new cassandra.auth.PlainTextAuthProvider(config.cassandra.username, config.cassandra.password);

let defaultLoggerOptions = {
  table: "logs",
  level: "debug",
  consistency: cassandra.types.consistencies.one,
  contactPoints: config.cassandra.contactPoints,
  keyspace: config.cassandra.keyspace,
  authProvider: authProvider,
  name: "cassandraDefaultLog"
};

let errorLoggerOptions = {
  table: "log_exceptions",
  level: "error",
  consistency: cassandra.types.consistencies.one,
  contactPoints: config.cassandra.contactPoints,
  keyspace: config.cassandra.keyspace,
  authProvider: authProvider,
  handleExceptions: true,
  name: "cassandraErrorLog"
};

winston.add(winstonCassandra, defaultLoggerOptions);
winston.add(winstonCassandra, errorLoggerOptions);

if(config.env != 'development')
{
  winston.remove(winston.transports.Console);
}

0 个答案:

没有答案