You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Benjamin Asbach (Jira)" <ji...@apache.org> on 2020/06/19 16:02:00 UTC

[jira] [Commented] (LOG4J2-2875) StreamClosed IOException after first time based rolling

    [ https://issues.apache.org/jira/browse/LOG4J2-2875?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17140658#comment-17140658 ] 

Benjamin Asbach commented on LOG4J2-2875:
-----------------------------------------

This creates the folder for logger initialization: https://github.com/apache/logging-log4j2/blob/log4j-2.13.3/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/AbstractRolloverStrategy.java#L111-L117

> StreamClosed IOException after first time based rolling
> -------------------------------------------------------
>
>                 Key: LOG4J2-2875
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2875
>             Project: Log4j 2
>          Issue Type: Bug
>    Affects Versions: 2.13.3
>            Reporter: Benjamin Asbach
>            Priority: Major
>
> 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:
> {code:java}
> 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);
>    }
>  }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)