At 18:06 11.04.2001 +0100, you wrote:
>Ceki,
>
>> 
>> What Paul described is certainly true for the newest code in our 
>CVS rep. As far as I know, 1.1b1 or any previous version the 
>PatternLayout does time stamping when formatting the event, not 
>when the event was created. This was a silly bug that has been 
>corrected in the code in our CVS rep. In other words, in 1.1b2 and 
>later versions, PatternLayout will use the time stamp that was 
>minted when the LoggingEvent was created or approximately at the 
>same time as the logging statement was invoked. Hope this further 
>clarifies the matter, Ceki
>
>Many thanks - was beginning to think I was seeing things!
>
>Not that familiar with CVS or the Dev. source trees. Can I just grab 
>a copy, and are there any "stability" issues i.e. whay stage is 
>version 1.1b2 in the develop/test cycle?

1.1b1 is basically a maintenance release ironing out rough edges with 1.0.4. On the 
other hand, 1.1b2 has a number of changes, in particular the JavaBeans type 
configuration added by Anders Kristensen. The new code passes our regression tests so 
it should be quite OK. 

The problem with code in our CVS repository is that changes can be committed before 
being fully tested. So the code in the CVS rep is not guaranteed to work well in 
production environments. 

Coming back to the issue at hand, I suggest that you simply patch 1.1b1 by changing
org/apache/log4j/helpers/PatternParser.java. See 
http://jakarta.apache.org/site/cvsindex.html for changes that occured in 
PatternParser.java.

The relevant patch is copied below:


===================================================================
RCS file: 
/home/cvs/jakarta-log4j/src/java/org/apache/log4j/helpers/PatternParser.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- jakarta-log4j/src/java/org/apache/log4j/helpers/PatternParser.java  2001/01/22 
10:57:27     1.4
+++ jakarta-log4j/src/java/org/apache/log4j/helpers/PatternParser.java  2001/03/20 
+16:05:46     1.5
@@ -22,6 +22,7 @@
 
 // Contributors:   Nelson Minar <([EMAIL PROTECTED]>
 //                 Igor E. Poteryaev <[EMAIL PROTECTED]>  
+//                 Reinhard Deschler <[EMAIL PROTECTED]> 
 
 /**
    Most of the work of the {@link org.apache.log4j.PatternLayout} class
@@ -426,7 +427,7 @@
 
     public
     String convert(LoggingEvent event) {
-      date.setTime(System.currentTimeMillis());
+      date.setTime(event.timeStamp);
       return df.format(date);
     }
   }
@@ -477,7 +478,7 @@
 
        // We substract 1 from 'len' when assigning to 'end' to avoid out of
        // bounds exception in return r.substring(end+1, len). This can happen if
-       // precision is 1 and the category name ends with a dot. you 
+       // precision is 1 and the category name ends with a dot. 
        int end = len -1 ;
        for(int i = precision; i > 0; i--) {      
          end = n.lastIndexOf('.', end-1);



The modification that we are interested in is replacing 

 date.setTime(System.currentTimeMillis());

with

  date.setTime(event.timeStamp);

on line 430 or so in PatternParser.java. Regards, Ceki

ps: It's a lot of words for not much. As I said, it was a silly bug.



--
Ceki Gülcü     Web: http://qos.ch 
email: [EMAIL PROTECTED] or [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to