rigeacoss opened a new issue, #4480:
URL: https://github.com/apache/logging-log4j2/issues/4480

   ## Description
   
   `MemoryMappedFileAppender` does not honor the configured immediateFlush 
option.
   
   In `MemoryMappedFileAppender.Builder.build()`, the configured value is 
correctly passed to `MemoryMappedFileManager`,
   ```java
   final MemoryMappedFileManager manager =
       MemoryMappedFileManager.getFileManager(
           fileName,
           append,
           isImmediateFlush(),
           actualRegionLength,
           advertiseURI,
           layout);
   ```
   
   However, the `MemoryMappedFileAppender` constructor receives a hard-coded 
false.
   ```java
   return new MemoryMappedFileAppender(
       name,
       layout,
       getFilter(),
       manager,
       fileName,
       isIgnoreExceptions(),
       false,  // ignores the configured immediateFlush value
       advertise ? getConfiguration().getAdvertiser() : null,
       getPropertyArray());
   ```
   
   As a result, setting `immediateFlush`=`true` does not enable per-event 
flushing, contrary to the documented behavior.
   
   ## Suggested fix
   
   Replace the hard-coded false with `isImmediateFlush()`:
   
   ```java
    return new MemoryMappedFileAppender(
        name,
        layout,
        getFilter(),
        manager,
        fileName,
        isIgnoreExceptions(),
   -    false,
   +    isImmediateFlush(),
        advertise ? getConfiguration().getAdvertiser() : null,
        getPropertyArray());
   ```
   
   ## Related issues and pull requests
   
   PR #4325 addresses a similar problem in `ConsoleAppender` (also see #4262, 
#4327), in which a hard-coded constructor argument causes an appender to ignore 
its configured `immediateFlush` value.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

  • [I] `MemoryMappedFileAppende... rigeacoss (via GitHub) via notifications

Reply via email to