Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
2.13.3
-
None
-
None
Description
An IOException is occuring when the first time based rolling was done. It seems that the new folder is not created and because of that the log cannot be written.
Example:
import java.util.Properties; import org.apache.logging.log4j.core.Logger; import org.apache.logging.log4j.core.LoggerContext; import org.apache.logging.log4j.core.config.properties.PropertiesConfiguration; import org.apache.logging.log4j.core.config.properties.PropertiesConfigurationBuilder; import org.junit.jupiter.api.Test; public class RollingTest { @Test public void streamClosedError() throws Exception { Properties log4j2Properties = new Properties(); log4j2Properties.put("appender.localmsglog.type", "RollingFile"); log4j2Properties.put("appender.localmsglog.name", "localmsglog"); log4j2Properties.put("appender.localmsglog.filePattern", "C:/dev/tmp/log/%d{yyyy_MM_dd-mm}/messages-$${date:yyyy_MM_dd_HH_mm_ss}.log"); log4j2Properties.put("appender.localmsglog.policies.type", "Policies"); log4j2Properties.put("appender.localmsglog.policies.1.type", "TimeBasedTriggeringPolicy"); log4j2Properties.put("rootLogger.level", "info"); log4j2Properties.put("rootLogger.appenderRef.1.ref", "localmsglog"); PropertiesConfiguration config = new PropertiesConfigurationBuilder() .setRootProperties(log4j2Properties) .build(); org.apache.logging.log4j.core.config.Configurator.reconfigure(config); LoggerContext context = LoggerContext.getContext(false); Logger log = context.getRootLogger(); while(true) { log.info("AAA"); Thread.sleep(15000); } } }
Attachments
Issue Links
- is related to
-
LOG4J2-2883 Size based rolling stops working after first time base rolling
- Resolved