Bug 38559 - Monthly logs not generated at midnight with DailyRollingFileAppender
Summary: Monthly logs not generated at midnight with DailyRollingFileAppender
Alias: None
Product: Log4j - Now in Jira
Classification: Unclassified
Component: Appender (show other bugs)
Version: 1.2
Hardware: All All
: P2 major
Target Milestone: ---
Assignee: log4j-dev
Depends on:
Reported: 2006-02-07 21:13 UTC by Manjit
Modified: 2007-05-18 07:19 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Manjit 2006-02-07 21:13:48 UTC
I have an issue with the DailyRollingFileAppender when generating monthly log 
files.  Im using log4j version 1.2.8 but the same code is in 1.2.13.

The log files are generated depending on when the DailyRollingFileAppender 
class get initialized. For example if the class is initialized at 10:45am on 
some date then the log files are not generated until 00:45am on first day of 
next month.

I believe this is caused by the following code in the 
DailyRollingFileAppender.java file:

public Date getNextCheckDate(Date now) {

    switch(type) {
       case DailyRollingFileAppender.TOP_OF_MONTH:
	this.set(Calendar.DATE, 1);
	this.set(Calendar.HOUR_OF_DAY, 0);
	this.set(Calendar.SECOND, 0);
	this.set(Calendar.MILLISECOND, 0);
	this.add(Calendar.MONTH, 1);


It seems the 'MINUTE' attr is not set to zero:

this.set(Calendar.MINUTE, 0);

Could someone take a look at this.

Thank you for your support,
Comment 1 Curt Arnold 2006-09-01 05:12:14 UTC
Also would effect weekly rollovers.

Committed revs 439183 (trunk) and 439184 (1.2 branch).
Comment 2 pranay 2007-05-18 07:19:17 UTC