我目前是Node.js的新手。我遇到以下异常的问题。知道究竟是什么,这个例外意味着需要什么解决方案.. ????
Error: This socket is closed.
at WriteStream.Socket._write (net.js:635:19)
at doWrite (_stream_writable.js:219:10)
at writeOrBuffer (_stream_writable.js:209:5)
at WriteStream.Writable.write (_stream_writable.js:180:11)
at WriteStream.Socket.write (net.js:613:40)
at Console.log (/home/ubuntu/svnrepo/FoodiptoBackend/TransactionManagement/node_modules/winston/lib/winston/transports/console.js:78:20)
at emit (/home/ubuntu/svnrepo/FoodiptoBackend/TransactionManagement/node_modules/winston/lib/winston/logger.js:174:17)
at /home/ubuntu/svnrepo/FoodiptoBackend/TransactionManagement/node_modules/async/lib/async.js:108:13
at Array.forEach (native)
at _each (/home/ubuntu/svnrepo/FoodiptoBackend/TransactionManagement/node_modules/async/lib/async.js:32:24)
at Object.async.each (/home/ubuntu/svnrepo/FoodiptoBackend/TransactionManagement/node_modules/async/lib/async.js:107:9)
at Logger.log (/home/ubuntu/svnrepo/FoodiptoBackend/TransactionManagement/node_modules/winston/lib/winston/logger.js:202:9)
以下是我的应用程序中使用的记录器代码。
var winston = require("winston");
var moment = require("moment");
//Note : create directory for logs manually
var logFileName = process.cwd() + '/logs/' + moment().utc().format("YYYYMMDD") + '.log';
var logger = new (winston.Logger)({
transports: [
new (winston.transports.Console)(),
new (winston.transports.File)({
filename: logFileName,
handleExceptions: true, //same file shall be used for handling info as well as exception logs
json: true,
maxsize: 5242880,
timestamp: true
})
],
exitOnError: false //prevent exit if an uncaught exception occurs
});
//
// Handle errors
//
logger.on('error', function (err) {
//console.log("Error occured while logging");
});
module.exports = logger;