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

SizeBasedTriggeringPolicy with DefaultRolloverStrategy is not working

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.3
    • Fix Version/s: 2.3
    • Component/s: Appenders
    • Labels:
    • Environment:

      Linux
      IBM J9 VM (build 2.4, J2RE 1.6.0 IBM J9 2.4 Linux x86-32 jvmxi3260-20080816_22093 (JIT enabled, AOT enabled)

      Description

      Hi Team,

      I have used below given log4j file and expect my logs to be getting generated up to size 1 MB with limit of 5 files but files are not reaching to the max size and next files getting started written.

      1048596 Dec 1 18:31 A-2017-12-01-3.log
      449246 Dec 1 18:33 A-2017-12-01-1.log
      1048636 Dec 1 18:32 A-2017-12-01-2.log
      123424 Dec 1 18:33 A-2017-12-01-5.log
      565972 Dec 1 18:33 A-2017-12-01-4.log
      270800 Dec 1 18:33 A.log

      ---Log4j used ----

      <?xml version="1.0" encoding="UTF-8"?>
      <Configuration monitorInterval="5">
      <Appenders>
      <RollingFile name="Online" fileName="My_Logs_Path/A.log" append="true" immediateFlush="true" bufferedIO="false" filePattern="My_Logs_Path/A-%d

      {yyyy-MM-dd}-%i.log">
      <PatternLayout>
      <pattern>|%-5p|%d{yyyy-MM-dd|HH:mm:ss,SSS}|%X{InterfaceId}|%X{SeqNo}|%X{Ouid} %X{srch1} %X{BussRef}|${sys:hostname}|${sys:ApplicationComponent}|%X{ExternalRefSend}|%m||%C{6}:%L|%t%n</pattern>
      </PatternLayout>
      <Policies>
      <SizeBasedTriggeringPolicy size="1 MB" />
      </Policies>
      <DefaultRolloverStrategy max="5"/>
      <Filters>
      <ThresholdFilter level="FATAL" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
      <ThresholdFilter level="ERROR" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
      <ThresholdFilter level="WARN" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
      <ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
      <ThresholdFilter level="DEBUG" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
      </Filters>
      </RollingFile>

      <RollingFile name="abcd" fileName="My_Logs_Path/B.log" append="true" immediateFlush="true" bufferedIO="false" filePattern="My_Logs_Path/B-%d{yyyy-MM-dd}

      -%i.log">
      <PatternLayout>
      <pattern>|%-5p|%d

      {yyyy-MM-dd|HH:mm:ss,SSS}

      |%X

      {InterfaceId}|%X{SeqNo}|%X{Ouid} %X{srch1} %X{BussRef}|${sys:hostname}|${sys:ApplicationComponent}|%X{ExternalRefSend}|%m||%C{6}:%L|%t%n</pattern>
      </PatternLayout>
      <Policies>
      <SizeBasedTriggeringPolicy size="1 MB" />
      </Policies>
      <DefaultRolloverStrategy max="5"/>
      <Filters>
      <ThresholdFilter level="FATAL" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
      <ThresholdFilter level="ERROR" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
      <ThresholdFilter level="WARN" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
      <ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
      <ThresholdFilter level="DEBUG" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
      </Filters>
      </RollingFile>

      <RollingFile name="efgh" fileName="My_Logs_Path/C.log" append="true" immediateFlush="true" bufferedIO="false" filePattern="My_Logs_Path/C-%d{yyyy-MM-dd}-%i.log">
      <PatternLayout>
      <pattern>|%-5p|%d{yyyy-MM-dd|HH:mm:ss,SSS}|%X{InterfaceId}

      |%X

      {SeqNo}

      |%X

      {Ouid}

      %X

      {srch1}

      %X

      {BussRef}

      |${sys:hostname}|${sys:ApplicationComponent}|%X

      {ExternalRefSend}

      |%m||%C

      {6}:%L|%t%n</pattern>
      </PatternLayout>
      <Policies>
      <SizeBasedTriggeringPolicy size="1 MB" />
      </Policies>
      <DefaultRolloverStrategy max="5"/>
      <Filters>
      <ThresholdFilter level="FATAL" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
      <ThresholdFilter level="ERROR" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
      <ThresholdFilter level="WARN" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
      <ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
      <ThresholdFilter level="DEBUG" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
      </Filters>
      </RollingFile>

      <RollingFile name="CHANNEL_STATUS" fileName="My_Logs_Path/D.log" append="true" immediateFlush="true" bufferedIO="false" filePattern="My_Logs_Path/D-%d{yyyy-MM-dd}-%i.log">
      <PatternLayout>
      <pattern>|%-5p|%d{yyyy-MM-dd|HH:mm:ss,SSS}|${sys:hostname}|${sys:ApplicationComponent}|%m||%C{6}

      :%L|%t%n</pattern>
      </PatternLayout>
      <Policies>
      <SizeBasedTriggeringPolicy size="1 MB" />
      </Policies>
      <DefaultRolloverStrategy max="5"/>
      </RollingFile>
      </Appenders>
      <loggers>
      <logger name="TTTT" level="DEBUG">
      <appender-ref ref="Online" level="DEBUG"/>
      </logger>
      <logger name="AAAA" level="DEBUG">
      <appender-ref ref="abcd" level="DEBUG"/>
      </logger>
      <logger name="BBBB" level="DEBUG" additivity="false">
      <appender-ref ref="efgh"/>
      </logger>
      <logger name="CHANNEL_LOGGER" level="DEBUG" additivity="false">
      <appender-ref ref="CHANNEL_STATUS" level="DEBUG"/>
      </logger>
      <logger name="org.springframework" level="OFF">
      </logger>
      </loggers>
      </Configuration>

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              ajaypachlangia Ajay Pachlangia
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: