JSNLOg - Custom AjaxAppender does not execute if batchsize is set to one

27 Views Asked by At

I've been trying to build out a custom AjaxAppender with jsnlog.js and I'm noticing a strange behavior around the batch size setting. If I set the batch size to something greater than 1 it will work, otherwise it will not.

There is a default configuration for the AjaxAppender that works out of the box, so I would expect that I should be able to get a similar result, but have been unable to do so.

My code is below:

private initializeLogger() {
    this.rootlogger = this.JL('tss');
    const beforeSendExample = (xhr) => {
      xhr.setRequestHeader('X-Correlation-Id', this.correlationService.current.id);
    };
    this.ajaxAppender = JL.createAjaxAppender('ajaxAppenderTss');
    this.ajaxAppender.setOptions({
      level : JL.getAllLevel(),
      sendWithBufferLevel : JL.getErrorLevel(),
      storeInBufferLevel : -2147483648,
      bufferSize : 0, // buffering switch off by default
      batchSize : 1, // ------------------------------- DOES NOT WORK
      // batchSize : 2, // ------------------------------- This does work.
      maxBatchSize : 20,
      batchTimeout : 2147483647,
      sendTimeout : 5000,
      beforeSend: beforeSendExample
    });
    this.consoleAppender = JL.createConsoleAppender('consoleAppenderTss');

    this.rootlogger =  this.rootlogger.setOptions({
      level: JL.getAllLevel(),
      appenders: [this.ajaxAppender, this.consoleAppender]
    });
0

There are 0 best solutions below