即使winston logger exitOnError设置为false,节点进程仍会退出

时间:2016-05-06 15:13:28

标签: node.js logging winston

这是我的winston记录器配置。我将exitOnError设置为false,但节点进程仍会在出错时退出。还有其他选择吗?我还定义了process.on('uncaughtException', function(err) {},在我将winston logger加入混合之前曾经工作过 -

    var papertrailConfig = {
            humanReadableUnhandledException: true,
            enabled: true,
            level: 'info',
            host: 'logs4.papertrailapp.com',
            port: 10308,
            program: serviceName
    };

    // define transports
    var logTransports = [];

    var paperTrailTransport = new winston.transports.Papertrail(papertrailConfig);
    paperTrailTransport.exceptionsLevel = 'info';
    paperTrailTransport.colorize = true;
    var fileName = process.argv[2] || 'general';

    // production gets file and paperTrailTransport
        logTransports.push( new winston.transports.File({
            filename: 'service.log',
            timestamp: true,
            max: '100m',
            keep: 5,
            compress: true,
            json: false,
            level: 'info'
        }))

        logTransports.push(paperTrailTransport);
    }

    winston.handleExceptions(logTransports);

    var defaultLogger = createLogger();
    _.extend(createLogger, defaultLogger);
    module.exports = createLogger;

    function createLogger(loggerName){
        loggerName = loggerName || fileName;

        return new winston.Logger({
            level: 'debug',
            filters: [function(level, msg, meta){
                return msg;
            }],
            transports: logTransports,
            exitOnError: false
    });
    }

0 个答案:

没有答案