Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-1162

Memory-mapped file appender creates null-padded files.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.1
    • 2.5
    • Appenders
    • None

    Description

      Memory-mapped file appender creates null-padded files.

      If configured my app like this:

      <?xml version="1.0" encoding="UTF-8"?>
      <!-- Copyright 2014-2015 Rocket Software, Inc. All rights reserved. -->
      <Configuration status="WARN" monitorInterval="5">
        <Appenders>
          <Console name="Console" target="SYSTEM_OUT">
            <PatternLayout noConsoleNoAnsi="true"
              pattern="%style{%d}{white} %highlight{%-5level}{TRACE=white} %style{[%t][%logger]}{white} %highlight{%msg%n%throwable}{TRACE=white}" />
          </Console>
          <RollingRandomAccessFile name="RollingFile" append="false" fileName="/test/dv/logs/dv.log-OFF"
            filePattern="/test/dv/logs/$${date:yyyy-MM}/dv-%d{yyyy-MM-dd}-%i.log.gz">
            <PatternLayout>
              <Pattern>%d %-5level [%t][%logger] %msg%n%throwable</Pattern>
            </PatternLayout>
            <Policies>
              <SizeBasedTriggeringPolicy size="100 MB" />
            </Policies>
          </RollingRandomAccessFile>
          <MemoryMappedFile name="MemMapFile" append="false" fileName="/test/dv/logs/dv.log">
            <PatternLayout>
              <Pattern>%d %-5level [%t][%logger] %msg%n%throwable</Pattern>
            </PatternLayout>
          </MemoryMappedFile>
        </Appenders>
        <Loggers>
          <Root level="trace">
      <!--       <AppenderRef ref="Console" /> -->
      <!--       <AppenderRef ref="RollingFile" /> -->
            <AppenderRef ref="MemMapFile" />
          </Root>
          <Logger name="javax.management" level="INFO" />
          <Logger name="sun.rmi" level="INFO" />
          <Logger name="com.rs.dv.util.LoggerEnvironmentReporter" level="OFF" />
        </Loggers>
        <!-- Filters -->
        <Filters>
          <!-- SQL only -->
          <!-- <MarkerFilter marker="DV.SQL" onMatch="ACCEPT" onMismatch="DENY" /> <MarkerFilter marker="DV.SQL.QUERY" onMatch="ACCEPT" 
            onMismatch="DENY" /> <MarkerFilter marker="DV.SQL.UPDATE" onMatch="ACCEPT" onMismatch="DENY" /> -->
          <!-- No buffer hex dumps -->
          <!-- <MarkerFilter marker="DV.BUFFER" onMatch="DENY" onMismatch="NEUTRAL" /> -->
        </Filters>
      </Configuration>
      

      After the app runs, I have a 32 MB log file, with the later 2/3 of the file, all null bytes.

      Clearly, we need to limit what we write out.

      Attachments

        Activity

          People

            Unassigned Unassigned
            ggregory Gary D. Gregory
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: