mperdeck/jsnlog.js

Custom AjaxAppender does not execute if batchsize is set to one

john-babb-tss opened this issue · 0 comments

I'm not sure if this is a bug or not, but it looks like the custom ajax AjaxAppender will only work if you have a batch size > 1. Can you take a look at this and let me know why this is an issue, and or, if this is a expected?

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]
        });
    }