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

RollingRandomAccessFileAppender with DirectWriteRolloverStrategy requires a fileName

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.8.1
    • Fix Version/s: 2.9.0
    • Component/s: None
    • Labels:
      None

      Description

      Following the docs about RollingRandomAccessFileAppender with a DirectWrite rollover, the config should be:

      <RollingRandomAccessFile append="true" filePattern="application.log.%i" name="json-log">
          <filters>
              <ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="DENY"/>
          </filters>
      	<PatternLayout>
      		<Pattern>%m%n</Pattern>
      	</PatternLayout>
          <Policies>
              <SizeBasedTriggeringPolicy size="10 MB"/>
          </Policies>
          <DirectWriteRolloverStrategy maxFiles="10"/>
      </RollingRandomAccessFile>
      

      But then console shows:

      2017-06-01 14:31:04,396 main ERROR No filename was provided for FileAppender with name json-log
      2017-06-01 14:31:04,406 main ERROR Null object returned for RollingRandomAccessFile in appenders.
      2017-06-01 14:31:04,417 main ERROR Unable to locate appender "json-log" for logger config "root"
      

      If adding a fileName parameter, the logger can be used but the file is not rolling (same as LOG4J2-1906).

        Activity

        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 0b37ee7466284d6a012a092f7284d15c53b75803 in logging-log4j2's branch refs/heads/master from Ralph Goers
        [ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=0b37ee7 ]

        LOG4J2-1928 - Add support for DirectWriteRolloverStrategy to RollingRandomAcessFileAppender

        Show
        jira-bot ASF subversion and git services added a comment - Commit 0b37ee7466284d6a012a092f7284d15c53b75803 in logging-log4j2's branch refs/heads/master from Ralph Goers [ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=0b37ee7 ] LOG4J2-1928 - Add support for DirectWriteRolloverStrategy to RollingRandomAcessFileAppender
        Hide
        ralph.goers@dslextreme.com Ralph Goers added a comment -

        The fix for this has been committed. Please verify and close.

        Show
        ralph.goers@dslextreme.com Ralph Goers added a comment - The fix for this has been committed. Please verify and close.
        Hide
        akurilov123 Andrey Kurilov added a comment - - edited

        The fix doesn't work in v2.9.0
        If the "fileName" attribute is left (worked in 2.8.2) the following error message is seen:

        2017-09-08 13:00:03,245 main ERROR The fileName attribute must not be specified with the DirectWriteRolloverStrategy
        

        If the "fileName" attribute is removed, NPE occurs:

        2017-09-08 13:07:41,398 main ERROR Could not create plugin of type class org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender for element appender: java.lang.NullPointerException java.lang.NullPointerException
        	at org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager.writeHeader(RollingRandomAccessFileManager.java:90)
        	at org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager.<init>(RollingRandomAccessFileManager.java:75)
        	at org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager$RollingRandomAccessFileManagerFactory.createManager(RollingRandomAccessFileManager.java:240)
        	at org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager$RollingRandomAccessFileManagerFactory.createManager(RollingRandomAccessFileManager.java:189)
        	at org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:113)
        	at org.apache.logging.log4j.core.appender.OutputStreamManager.getManager(OutputStreamManager.java:115)
        	at org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager.getRollingRandomAccessFileManager(RollingRandomAccessFileManager.java:109)
        	at org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender$Builder.build(RollingRandomAccessFileAppender.java:131)
        	at org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender$Builder.build(RollingRandomAccessFileAppender.java:52)
        	at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:122)
        	at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:958)
        	at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:898)
        	at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:890)
        	at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:513)
        	at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:237)
        	at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:249)
        	at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:545)
        	at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:617)
        	at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:634)
        	at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:229)
        	at org.apache.logging.log4j.core.async.AsyncLoggerContext.start(AsyncLoggerContext.java:76)
        	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:242)
        	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
        	at org.apache.logging.log4j.LogManager.getContext(LogManager.java:174)
        	at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:618)
                ...
        
        Show
        akurilov123 Andrey Kurilov added a comment - - edited The fix doesn't work in v2.9.0 If the "fileName" attribute is left (worked in 2.8.2) the following error message is seen: 2017-09-08 13:00:03,245 main ERROR The fileName attribute must not be specified with the DirectWriteRolloverStrategy If the "fileName" attribute is removed, NPE occurs: 2017-09-08 13:07:41,398 main ERROR Could not create plugin of type class org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender for element appender: java.lang.NullPointerException java.lang.NullPointerException at org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager.writeHeader(RollingRandomAccessFileManager.java:90) at org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager.<init>(RollingRandomAccessFileManager.java:75) at org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager$RollingRandomAccessFileManagerFactory.createManager(RollingRandomAccessFileManager.java:240) at org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager$RollingRandomAccessFileManagerFactory.createManager(RollingRandomAccessFileManager.java:189) at org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:113) at org.apache.logging.log4j.core.appender.OutputStreamManager.getManager(OutputStreamManager.java:115) at org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager.getRollingRandomAccessFileManager(RollingRandomAccessFileManager.java:109) at org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender$Builder.build(RollingRandomAccessFileAppender.java:131) at org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender$Builder.build(RollingRandomAccessFileAppender.java:52) at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:122) at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:958) at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:898) at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:890) at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:513) at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:237) at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:249) at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:545) at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:617) at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:634) at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:229) at org.apache.logging.log4j.core.async.AsyncLoggerContext.start(AsyncLoggerContext.java:76) at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:242) at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45) at org.apache.logging.log4j.LogManager.getContext(LogManager.java:174) at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:618) ...

          People

          • Assignee:
            ralph.goers@dslextreme.com Ralph Goers
            Reporter:
            lucasvc Lucas Ventura Carro
          • Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development