Skip to content Skip to sidebar Skip to footer

How To Log Unhandled Timeouterror In Winstonjs Logger?

I've got a node application in which I use Winstonjs as a logger. In my logger I've got a specific part for logging exceptions like this: const myFormat = winston.format.printf(inf

Solution 1:

The process is referring to node. Try to add a unhandledRejection check in your index.js or use proper winston exception handling:

"use strict";

const winston = require('winston');

const myFormat = winston.format.printf(info => {
    return`${info.timestamp}${info.level}: ${info.message}`;
});
const logger = winston.createLogger({
    level: "debug",
    format: winston.format.combine(winston.format.timestamp(), myFormat),  // winston.format.json(),transports: [
        new winston.transports.File({filename: "logs/error.log", level: 'error'}),
        new winston.transports.File({filename: 'logs/combined.log'}),
    ],
    exceptionHandlers: [
        new winston.transports.File({ filename: 'logs/exceptions.log' }),
        new winston.transports.File({ filename: 'logs/combined.log' })
    ],
    exitOnError: false,
    // handleExceptions: true // Otherwise, you should use this in options.
});

process.on('unhandledRejection', (reason, promise) => {
    logger.debug(reason);
});

process.on('uncaughtException', (err) => {
    logger.debug(err);
});

However, look in your package.json file in the same directory as the index.js file. Look in dependencies section for node-pool and change its version to "node-pool": "^3.4.2" since the problem you describe is most likely fixed in the 3.1.8 release.

Post a Comment for "How To Log Unhandled Timeouterror In Winstonjs Logger?"