diff --git a/lib/appenders/dateFile.js b/lib/appenders/dateFile.js index 411bc5b..7eaeef4 100644 --- a/lib/appenders/dateFile.js +++ b/lib/appenders/dateFile.js @@ -65,6 +65,9 @@ function shutdown(cb) { cb(error); } }; + if (!openFiles.length) { + return cb(); + } openFiles.forEach(function(file) { if (!file.write(eol, "utf-8")) { file.once('drain', function() { diff --git a/lib/appenders/file.js b/lib/appenders/file.js index 8ad530e..5b2959e 100644 --- a/lib/appenders/file.js +++ b/lib/appenders/file.js @@ -93,6 +93,9 @@ function shutdown(cb) { cb(error); } }; + if (!openFiles.length) { + return cb(); + } openFiles.forEach(function(file) { if (!file.write(eol, "utf-8")) { file.once('drain', function() { diff --git a/lib/log4js.js b/lib/log4js.js index 68ca51b..4e3a4da 100644 --- a/lib/log4js.js +++ b/lib/log4js.js @@ -444,6 +444,9 @@ function shutdown(cb) { shutdownFcts.push(appenderShutdowns[category]); } } + if (!shutdownFcts.length) { + return cb(); + } shutdownFcts.forEach(function(shutdownFct) { shutdownFct(complete); }); }