You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Taisuke Tashiro (JIRA)" <ji...@apache.org> on 2015/12/09 02:56:10 UTC
[jira] [Commented] (LOG4J2-1205) RollingFileAppender logs first log
to old dated file
[ https://issues.apache.org/jira/browse/LOG4J2-1205?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15047860#comment-15047860 ]
Taisuke Tashiro commented on LOG4J2-1205:
-----------------------------------------
It is not due to a frequency of rollover check. TimeBasedTriggeringPolicy.isTriggeringEvent method always returns false when active file size is 0. This prevents rollover on first logging and rollover is always triggered on second logging. Which results as first log on wrong file.
I think this issue can be avoided by updating the time stamp of existing 0 byte file on initialization of RollingFileManager (RollingFileManagerFactory.creataManager).
Or, 0 byte check may not be necessary since rollover check is always performed with file output on log event and 0 byte file is created only on RollingFileManager initialization.
> RollingFileAppender logs first log to old dated file
> ----------------------------------------------------
>
> Key: LOG4J2-1205
> URL: https://issues.apache.org/jira/browse/LOG4J2-1205
> Project: Log4j 2
> Issue Type: Bug
> Components: Appenders
> Affects Versions: 2.2
> Environment: The issue can be recreated in both Windows 7 and AIX.
> Reporter: Taisuke Tashiro
>
> When empty log file (0 byte) with old time stamp exists, RollingFileAppender logs first log to the rolled file.
> For example, when given the following configuration,
> {code}
> <RollingFile
> name="RollingFile"
> fileName="rolling.log"
> filePattern="rolling.log.%d{yyyyMMdd}">
> <PatternLayout pattern="%d{yyyy-MM-dd} %msg%n" />
> </RollingFile>
> {code}
> and empty rolling.log file exists with time stamp 2015-11-01, after logging two log records (say today) result as followings.
> rolling.log.201511{color:red}01{color}
> {quote}
> 2015-11-{color:red}25{color} FIRST LOG
> {quote}
> rolling.log
> {quote}
> 2015-11-25 SECOND LOG
> {quote}
> Both record should be logged in rolling.log file and no dated file created.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org