You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "su pei tao (Jira)" <ji...@apache.org> on 2022/07/30 19:40:00 UTC
[jira] [Created] (LOG4J2-3565) RollingRandomAccessFileAppender with DirectWriteRolloverStrategy can't create the first log file of different directory
su pei tao created LOG4J2-3565:
----------------------------------
Summary: 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
Reporter: su pei tao
If 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}
<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:java}
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)