diff --git a/lib/winston/logger.js b/lib/winston/logger.js index 936a13b8f..27d3af8bb 100755 --- a/lib/winston/logger.js +++ b/lib/winston/logger.js @@ -461,7 +461,9 @@ Logger.prototype.add = function (transport, options, created) { // Listen for the `error` event on the new Transport // instance._onError = this._onError.bind(this, instance) - instance.on('error', instance._onError); + if (! created) { + instance.on('error', instance._onError); + } // // If this transport has `handleExceptions` set to `true` @@ -529,7 +531,9 @@ Logger.prototype.remove = function (transport) { instance.close(); } - instance.removeListener('error', instance._onError); + if (instance._onError) { + instance.removeListener('error', instance._onError); + } return this; };