Skip to content

MemoryMappedFileAppender ignores immediateFlush=true due to hard-coded false #4480

Open

Description

@rigeacoss

Expected: immediateFlush="true" on MemoryMappedFile forces the mapped buffer after every event.
Actual: the appender's own flag is always false (getImmediateFlush() returns false); only the manager receives the configured true.
Affects: 2.25.3 and 2.26.1, 2.x and main heads.
Reproducer: configure <MemoryMappedFile immediateFlush="true">, read getImmediateFlush() from the appender after startup.

Original report:

Description

MemoryMappedFileAppender does not honor the configured immediateFlush option.

In MemoryMappedFileAppender.Builder.build(), the configured value is correctly passed to MemoryMappedFileManager,

final MemoryMappedFileManager manager =
    MemoryMappedFileManager.getFileManager(
        fileName,
        append,
        isImmediateFlush(),
        actualRegionLength,
        advertiseURI,
        layout);

However, the MemoryMappedFileAppender constructor receives a hard-coded false.

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():

 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.

Activity

  1. ramanathan1504 commented on Nov 14, 2026

    @ramanathan1504
    Contributor

    Thanks, confirmed: MemoryMappedFileAppender.Builder.build() hands the configured value to the manager but a literal false to the appender, so the mapped buffer is only forced at end of batch, remap or close. Same on 2.x and main.
    Your one-line fix is the right one. A PR against 2.x with a test in MemoryMappedFileAppenderTest asserting getImmediateFlush() for both values, plus a changelog entry like 4262_console_immediate_flush.xml, would be welcome.

  2. added
    bugIncorrect, unexpected, or unintended behavior of existing code
    appendersAffects one or more Appender plugins
    and removed on Nov 14, 2026
  3. added a commit that references this issue on Nov 14, 2026
    96b364a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    appendersAffects one or more Appender pluginsbugIncorrect, unexpected, or unintended behavior of existing code

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions