Bug 38559

Summary: Monthly logs not generated at midnight with DailyRollingFileAppender
Product: Log4j - Now in Jira Reporter: Manjit <mgrewal>
Component: AppenderAssignee: log4j-dev <log4j-dev>
Status: RESOLVED FIXED    
Severity: major    
Priority: P2    
Version: 1.2   
Target Milestone: ---   
Hardware: All   
OS: All   

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) {
    this.setTime(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);
	break;

...}
}

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,
Manjit
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
gfhg