You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2022/08/04 19:38:00 UTC
[jira] [Commented] (LOG4J2-3565) RollingRandomAccessFileAppender with DirectWriteRolloverStrategy can't create the first log file of different directory
[ https://issues.apache.org/jira/browse/LOG4J2-3565?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17575412#comment-17575412 ]
ASF subversion and git services commented on LOG4J2-3565:
---------------------------------------------------------
Commit 28efddbcd5fd9f83ea299d099a15dffbae9696a5 in logging-log4j2's branch refs/heads/release-2.x from dafengsu7
[ https://gitbox.apache.org/repos/asf?p=logging-log4j2.git;h=28efddbcd5 ]
[LOG4J2-3565] Fix RollingRandomAccessFileAppender with DirectWriteRolloverStrategy can't create the first log file of different directory.
> 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)