logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1519776 - in /logging/log4j/log4j2/trunk: log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/ log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ src/changes/
Date Tue, 03 Sep 2013 18:07:51 GMT
Author: rgoers
Date: Tue Sep  3 18:07:50 2013
New Revision: 1519776

URL: http://svn.apache.org/r1519776
Log:
LOG4J2-380 - Use rollover date when substituting  in the filePattern.

Modified:
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/PatternProcessor.java
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java
    logging/log4j/log4j2/trunk/src/changes/changes.xml

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java?rev=1519776&r1=1519775&r2=1519776&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java
Tue Sep  3 18:07:50 2013
@@ -115,10 +115,10 @@ public class DefaultRolloverStrategy imp
             }
 
             final StringBuilder buf = new StringBuilder();
-            manager.getPatternProcessor().formatFileName(buf, fileIndex);
+            manager.getPatternProcessor().formatFileName(subst, buf, fileIndex);
             final String currentFileName = manager.getFileName();
 
-            String renameTo = subst.replace(buf);
+            String renameTo = buf.toString();
             final String compressedName = renameTo;
             Action compressAction = null;
 

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/PatternProcessor.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/PatternProcessor.java?rev=1519776&r1=1519775&r2=1519776&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/PatternProcessor.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/PatternProcessor.java
Tue Sep  3 18:07:50 2013
@@ -21,6 +21,9 @@ import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
 
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.impl.Log4jLogEvent;
+import org.apache.logging.log4j.core.lookup.StrSubstitutor;
 import org.apache.logging.log4j.core.pattern.ArrayPatternConverter;
 import org.apache.logging.log4j.core.pattern.DatePatternConverter;
 import org.apache.logging.log4j.core.pattern.FormattingInfo;
@@ -169,6 +172,21 @@ public class PatternProcessor {
 
     /**
      * Format file name.
+     * @param subst The StrSubstitutor.
+     * @param buf string buffer to which formatted file name is appended, may not be null.
+     * @param obj object to be evaluated in formatting, may not be null.
+     */
+    public final void formatFileName(final StrSubstitutor subst, final StringBuilder buf,
final Object obj) {
+        final long time = prevFileTime == 0 ? System.currentTimeMillis() : prevFileTime;
+        formatFileName(buf, new Date(time), obj);
+        LogEvent event = new Log4jLogEvent(time);
+        String fileName = subst.replace(event, buf);
+        buf.setLength(0);
+        buf.append(fileName);
+    }
+
+    /**
+     * Format file name.
      * @param buf string buffer to which formatted file name is appended, may not be null.
      * @param objects objects to be evaluated in formatting, may not be null.
      */

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java?rev=1519776&r1=1519775&r2=1519776&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java
Tue Sep  3 18:07:50 2013
@@ -55,6 +55,13 @@ public class Log4jLogEvent implements Lo
     private boolean endOfBatch = false;
 
     /**
+     *
+     */
+    public Log4jLogEvent(final long timestamp) {
+        this("", null, "", null, null, (ThrowableProxy) null, null, null, null, null, timestamp);
+    }
+
+    /**
      * Constructor.
      * @param loggerName The name of the Logger.
      * @param marker The Marker or null.

Modified: logging/log4j/log4j2/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/changes/changes.xml?rev=1519776&r1=1519775&r2=1519776&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/changes/changes.xml (original)
+++ logging/log4j/log4j2/trunk/src/changes/changes.xml Tue Sep  3 18:07:50 2013
@@ -21,8 +21,11 @@
   </properties>
   <body>
     <release version="2.0-beta9" date="soon, very soon" description="Bug fixes and enhancements">
+      <action issue="LOG4J2-380" dev="rgoers" type="fix">
+        Use rollover date when substituting ${date} in the filePattern.
+      </action>
       <action issue="LOG4J2-317" dev="ggregory" type="update">
-        Renamed FastFileAppender and FastRollingFileAppender to RandomAccessFileAppender

+        Renamed FastFileAppender and FastRollingFileAppender to RandomAccessFileAppender
         and RollingRandomAccessFileAppender. Configurations using the Fast(Rolling)File element
         no longer work and should be modified to use the (Rolling)RandomAccessFile element.
       </action>



Mime
View raw message