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 bu...@apache.org on 2009/03/13 16:36:07 UTC

DO NOT REPLY [Bug 46851] New: DailyRollingFileAppender with DatePattern='.'yyyy-ww gives monthly log rotation if the default locale is Locale.GERMAN

https://issues.apache.org/bugzilla/show_bug.cgi?id=46851

           Summary: DailyRollingFileAppender with DatePattern='.'yyyy-ww
                    gives monthly log rotation if the default locale is
                    Locale.GERMAN
           Product: Log4j
           Version: 1.2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: PatchAvailable
          Severity: normal
          Priority: P2
         Component: Appender
        AssignedTo: log4j-dev@logging.apache.org
        ReportedBy: strozyk@adesso.de


Using the DailyRollingFileAppender with DatePattern='.'yyyy-ww gives monthly
log rotation if the default locale of the JVM is Locale.GERMAN.

Expected is weekly log rotation as documented in JavaDoc.


I think the reason for this issue is that in method
DailyRollingFileAppender.computeCheckPeriod:
-the RollingCalendar instance is explicitly constructed with Locale.ENGLISH,
which gives SUNDAY as first day of week
-in the SimpleDateFormat instance, only timezone is set. Therefore, in germany
simpleDateFormat uses a Calendar with Locale.GERMAN, which gives MONDAY as
first day of week
Then, rollingCalendar.getNextCheckMillis() returns a Sunday, which belongs to
the same week as epoch from SimpleDateFormat's point of view.

I suggest to fix the problem by removing -line and adding +lines as follows:

  int computeCheckPeriod() {
    RollingCalendar rollingCalendar = new RollingCalendar(gmtTimeZone,
Locale.ENGLISH);
    // set sate to 1970-01-01 00:00:00 GMT
    Date epoch = new Date(0);
    if(datePattern != null) {
      for(int i = TOP_OF_MINUTE; i <= TOP_OF_MONTH; i++) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(datePattern);
-       simpleDateFormat.setTimeZone(gmtTimeZone); // do all date formatting in
GMT
+       // do all date formatting in GMT and with ENGLISH locale settings
+       Calendar formatCal = Calendar.getInstance(gmtTimeZone, Locale.ENGLISH);
+       simpleDateFormat.setCalendar(formatCal);
        String r0 ( https://svn.apache.org/viewcvs.cgi?view=rev&rev=0 )= simpleDateFormat.format(epoch);
        rollingCalendar.setType(i);
        Date next = new Date(rollingCalendar.getNextCheckMillis(epoch));
        String r1 ( https://svn.apache.org/viewcvs.cgi?view=rev&rev=1 )=  simpleDateFormat.format(next);
        //System.out.println("Type = "+i+", r0 ( https://svn.apache.org/viewcvs.cgi?view=rev&rev=0 )= "+r0 ( https://svn.apache.org/viewcvs.cgi?view=rev&rev=0 )", r1 ( https://svn.apache.org/viewcvs.cgi?view=rev&rev=1 )= "+r1 ( https://svn.apache.org/viewcvs.cgi?view=rev&rev=1 );
        if(r0 ( https://svn.apache.org/viewcvs.cgi?view=rev&rev=0 )!= null && r1 ( https://svn.apache.org/viewcvs.cgi?view=rev&rev=1 )!= null && !r0 ( https://svn.apache.org/viewcvs.cgi?view=rev&rev=0 )equals(r1 ( https://svn.apache.org/viewcvs.cgi?view=rev&rev=1 )) {
          return i;
        }
      }
    }
    return TOP_OF_TROUBLE; // Deliberately head for trouble...
  }

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


DO NOT REPLY [Bug 46851] DailyRollingFileAppender with DatePattern='.'yyyy-ww gives monthly log rotation if the default locale is Locale.GERMAN

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46851

Curt Arnold <ca...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE

--- Comment #1 from Curt Arnold <ca...@apache.org> 2009-10-10 11:24:26 UTC ---
Code fragment appears to predate the patch for 40888.  Believe the suggested
change and the 40888 change are incompatibility.  Please reopen (or file a new
bug) if the current SVN HEAD does not resolve the issue.

*** This bug has been marked as a duplicate of bug 40888 ***

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


DO NOT REPLY [Bug 46851] DailyRollingFileAppender with DatePattern='.'yyyy-ww gives monthly log rotation if the default locale is Locale.GERMAN

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46851


Olaf Strozyk <st...@adesso.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |strozyk@adesso.de




-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org