[ 
https://issues.apache.org/jira/browse/LOG4J2-3565?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

su pei tao updated LOG4J2-3565:
-------------------------------
    Affects Version/s: 2.17.2
                       2.18.0

> RollingRandomAccessFileAppender with DirectWriteRolloverStrategy can't create 
>  the first log file of different directory
> ------------------------------------------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-3565
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-3565
>             Project: Log4j 2
>          Issue Type: Bug
>    Affects Versions: 2.18.0, 2.17.2
>            Reporter: su pei tao
>            Priority: Major
>
> When you want split the log into different directories by period (day, hour, 
> minute, etc.), and use
> [RollingRandomAccessFileAppender|https://logging.apache.org/log4j/2.x/manual/appenders.html#RollingRandomAccessFileAppender]
>  with a [DirectWrite 
> rollover|https://logging.apache.org/log4j/2.x/manual/appenders.html#RolloverStrategies],
>  the config should be:
> {code:xml}
> <RollingRandomAccessFile name="RollingFile"  
> filePattern="${baseDir}/%d{s}/%d{s}.log">
>     <PatternLayout header= "${LOG_HEADER}">
>         <Pattern>${LOG_PATTERN}</Pattern>
>     </PatternLayout>
>     <Policies>
>         <TimeBasedTriggeringPolicy/>
>     </Policies>
> </RollingRandomAccessFile>
> {code}
>  At that time when you create the first log of each directory, console shows;
> {code:sh}
> 2022-07-31 03:17:44,009 main ERROR RollingRandomAccessFileManager 
> target/rolling-random-direct-switch-director/%d{s}/%d{s}.log Failed to create 
> file after rollover: java.io.FileNotFoundException: 
> target/rolling-random-direct-switch-director/44/44.log (No such file or 
> directory) java.io.FileNotFoundException: 
> target/rolling-random-direct-switch-director/44/44.log (No such file or 
> directory) 
> {code}
> Apparently the directory has not been created when the file is creating



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to