diff --git a/lib/log4js.js b/lib/log4js.js index 9d6209b..fdd48c8 100644 --- a/lib/log4js.js +++ b/lib/log4js.js @@ -103,13 +103,15 @@ function shutdown(cb) { debug(`Appender shutdowns complete: ${completed} / ${shutdownFunctions}`); if (completed >= shutdownFunctions) { debug("All shutdown functions completed."); - cb(error); + if (cb) { + cb(error); + } } } if (shutdownFunctions === 0) { debug("No appenders with shutdown functions found."); - return cb(); + return cb !== undefined && cb(); } appendersToCheck.filter(a => a.shutdown).forEach(a => a.shutdown(complete)); diff --git a/types/test.ts b/types/test.ts index 66c7ad3..4bb26c7 100644 --- a/types/test.ts +++ b/types/test.ts @@ -61,7 +61,7 @@ const logger5 = log4js.getLogger('json-test'); logger5.info('this is just a test'); logger5.error('of a custom appender'); logger5.warn('that outputs json'); -log4js.shutdown(() => { }); +log4js.shutdown(); log4js.configure({ appenders: {