Console object replacing not working in javascript

I have replaced the console object with the below code. My intention is to get all the logs written to the console and pass those to my logger component for sending to server
But when I tested it very few logs are passed to the logger component. Please help me identify the issue?

In the below code I have overridden almost all the functions in the console object.
Is there a chance that the browser provides different console objects for different components within the same app?

var console = (function (oldCons) {
  return {
    log: function () {
      var msg = '';
      for (var i = 0; i < arguments.length; i++) {
        msg += '--' + arguments[i];
      }
      oldCons.log('JJJJJJJJJJJJJJJJJJJJJ -----------' + msg);
      logger.logError("CN", "__oraco__route_c-start", "processRouteIdFromRouteAllocation()", "This is from log-------------" + msg);
    },
    info: function () {
      var msg = '';
      for (var i = 0; i < arguments.length; i++) {
        msg += '--' + arguments[i];
      }
      oldCons.info('JJJJJJJJJJJJJJJJJJJJJ -----------' + msg);
      logger.logError("CN", "__oraco__route_c-start", "processRouteIdFromRouteAllocation()", "This is from info-------------" + msg);
    },
    warn: function () {
      var msg = '';
      for (var i = 0; i < arguments.length; i++) {
        msg += '--' + arguments[i];
      }
      oldCons.warn('JJJJJJJJJJJJJJJJJJJJJ -----------' + msg);
      logger.logError("CN", "__oraco__route_c-start", "processRouteIdFromRouteAllocation()", "This is from warn-------------" + msg);
    },
    error: function () {
      var msg = '';
      for (var i = 0; i < arguments.length; i++) {
        msg += '--' + arguments[i];
      }
      oldCons.error('JJJJJJJJJJJJJJJJJJJJJ -----------' + msg);
      logger.logError("CN", "__oraco__route_c-start", "processRouteIdFromRouteAllocation()", "This is from error-------------" + msg);
    },
    assert: function () {
      var msg = '';
      var tmp = '';
      for (var i = 0; i < arguments.length; i++) {
        if (typeof arguments[i] === 'object') {
          tmp = JSON.parse(JSON.stringify(arguments[i]));
        } else {
          tmp = arguments[i];
        }
        msg += '--' + tmp;
      }
      oldCons.log('JJJJJJJJJJJJJJJJJJJJJ -----------' + msg);
      logger.logError("CN", "__oraco__route_c-start", "processRouteIdFromRouteAllocation()", "This is from error-------------" + msg);
    },
    clear: function () {
    },
    count: function () {
    },
    countReset: function () {
    },
    dir: function () {
      var msg = '';
      var tmp = '';
      for (var i = 0; i < arguments.length; i++) {
        if (typeof arguments[i] === 'object') {
          tmp = JSON.parse(JSON.stringify(arguments[i]));
        } else {
          tmp = arguments[i];
        }
        msg += '--' + tmp;
      }
      oldCons.log('JJJJJJJJJJJJJJJJJJJJJ -----------' + msg);
      logger.logError("CN", "__oraco__route_c-start", "processRouteIdFromRouteAllocation()", "This is from error-------------" + msg);
    },
    dirxml: function () {
    },
    group: function () {
    },
    groupCollapsed: function () {
    },
    groupEnd: function () {
    },
    table: function () {
    },
    time: function () {
    },
    timeEnd: function () {
    },
    timeLog: function () {
    },
    time: function () {
    },
    timeEnd: function () {
    },
    debug: function () {
      var msg = '';
      for (var i = 0; i < arguments.length; i++) {
        msg += '--' + arguments[i];
      }
      oldCons.error('JJJJJJJJJJJJJJJJJJJJJ -----------' + msg);
      logger.debug("CN", "__oraco__route_c-start", "processRouteIdFromRouteAllocation()", "This is from error-------------" + msg);
    },
    trace: function () {
      var msg = '';
      for (var i = 0; i < arguments.length; i++) {
        msg += '--' + arguments[i];
      }
      oldCons.trace('JJJJJJJJJJJJJJJJJJJJJ -----------' + msg);
      logger.logError("CN", "__oraco__route_c-start", "processRouteIdFromRouteAllocation()", "This is from error-------------" + msg);
    }
  };
}(window.console));

window.console = console;