Description
If a RollingRandomAccessFileAppender is configured using the DirectWriteRolloverStrategy and there is no log event which is passed to this appender there will be a NullPointerException when the configuration is stoped.
java.lang.NullPointerException at org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager.closeOutputStream(RollingRandomAccessFileManager.java:168) at org.apache.logging.log4j.core.appender.OutputStreamManager.releaseSub(OutputStreamManager.java:136) at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.releaseSub(RollingFileManager.java:266) at org.apache.logging.log4j.core.appender.AbstractManager.stop(AbstractManager.java:86) at org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender.stop(AbstractOutputStreamAppender.java:142) at org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender.stop(RollingRandomAccessFileAppender.java:223) at org.apache.logging.log4j.core.config.AbstractConfiguration.stop(AbstractConfiguration.java:360) at org.apache.logging.log4j.core.AbstractLifeCycle.stop(AbstractLifeCycle.java:136) at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:552) at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:619) at org.apache.logging.log4j.core.LoggerContext.setConfigLocation(LoggerContext.java:605) at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:157) at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:70) at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:228) at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:158) at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:131) at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:101) at org.apache.logging.log4j.junit.LoggerContextRule$1.evaluate(LoggerContextRule.java:120) at org.junit.rules.RunRules.evaluate(RunRules.java:20) [...]
To reproduce the issue a config may be created wich does not use this appender:
<Configuration status="WARN"> <Appenders> <Console name="Console" target="SYSTEM_OUT"></Console> <RollingRandomAccessFile name="DatedLogFile" filePattern="log.%d{yyyyMMdd}" immediateFlush="false"> <TimeBasedTriggeringPolicy /> <DirectWriteRolloverStrategy /> </RollingRandomAccessFile> </Appenders> <Loggers> <Root level="warn"> <AppenderRef ref="Console" /> </Root> </Loggers> </Configuration>
Attachments
Issue Links
- is duplicated by
-
LOG4J2-2510 RollingRandomAccessFileManager throws NPE in closeOutputStream on shutdown
- Closed
- is related to
-
LOG4J2-2247 RollingRandomAccessFile appender with DirectWriteRolloverStrategy fails with a NullPointerException when a header is supplied
- Closed