Author: rgoers
Date: Fri Dec 30 23:53:24 2011
New Revision: 1225972

URL: http://svn.apache.org/viewvc?rev=1225972&view=rev
Log:
Add DateLookup. Make DefaultRolloverStrategy interpolate the file pattern.

Added:
    
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/DateLookup.java
      - copied, changed from r1224872, 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/EnvironmentLookup.java
    
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/lookup/DateLookupTest.java
      - copied, changed from r1220999, 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/lookup/EnvironmentLookupTest.java
Modified:
    
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/RollingFileAppender.java
    
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java
    
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-rolling1.xml
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/src/site/site.xml
    
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/src/site/xdoc/manual/appenders.xml
    
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/src/site/xdoc/manual/lookups.xml

Modified: 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/RollingFileAppender.java
URL: 
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/RollingFileAppender.java?rev=1225972&r1=1225971&r2=1225972&view=diff
==============================================================================
--- 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/RollingFileAppender.java
 (original)
+++ 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/RollingFileAppender.java
 Fri Dec 30 23:53:24 2011
@@ -23,8 +23,10 @@ import org.apache.logging.log4j.core.app
 import org.apache.logging.log4j.core.appender.rolling.RollingFileManager;
 import org.apache.logging.log4j.core.appender.rolling.RolloverStrategy;
 import org.apache.logging.log4j.core.appender.rolling.TriggeringPolicy;
+import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.plugins.Plugin;
 import org.apache.logging.log4j.core.config.plugins.PluginAttr;
+import org.apache.logging.log4j.core.config.plugins.PluginConfiguration;
 import org.apache.logging.log4j.core.config.plugins.PluginElement;
 import org.apache.logging.log4j.core.config.plugins.PluginFactory;
 import org.apache.logging.log4j.core.layout.PatternLayout;
@@ -93,6 +95,7 @@ public final class RollingFileAppender e
      * @param filter The Filter or null.
      * @param suppress "true" if exceptions should be hidden from the 
application, "false" otherwise.
      * The default is "true".
+     * @param config The Configuration.
      * @return A RollingFileAppender.
      */
     @PluginFactory
@@ -106,7 +109,8 @@ public final class RollingFileAppender e
                                               @PluginElement("strategy") 
RolloverStrategy strategy,
                                               @PluginElement("layout") Layout 
layout,
                                               @PluginElement("filter") Filter 
filter,
-                                              
@PluginAttr("suppressExceptions") String suppress) {
+                                              
@PluginAttr("suppressExceptions") String suppress,
+                                              @PluginConfiguration 
Configuration config) {
 
         boolean isAppend = append == null ? true : Boolean.valueOf(append);
         boolean handleExceptions = suppress == null ? true : 
Boolean.valueOf(suppress);
@@ -134,7 +138,7 @@ public final class RollingFileAppender e
         }
 
         if (strategy == null) {
-            strategy = DefaultRolloverStrategy.createStrategy(null, null);
+            strategy = DefaultRolloverStrategy.createStrategy(null, null, 
config);
         }
 
         RollingFileManager manager = 
RollingFileManager.getFileManager(fileName, filePattern, isAppend, isBuffered);

Modified: 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java
URL: 
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java?rev=1225972&r1=1225971&r2=1225972&view=diff
==============================================================================
--- 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java
 (original)
+++ 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java
 Fri Dec 30 23:53:24 2011
@@ -21,9 +21,12 @@ import org.apache.logging.log4j.core.app
 import org.apache.logging.log4j.core.appender.rolling.helper.FileRenameAction;
 import org.apache.logging.log4j.core.appender.rolling.helper.GZCompressAction;
 import org.apache.logging.log4j.core.appender.rolling.helper.ZipCompressAction;
+import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.plugins.Plugin;
 import org.apache.logging.log4j.core.config.plugins.PluginAttr;
+import org.apache.logging.log4j.core.config.plugins.PluginConfiguration;
 import org.apache.logging.log4j.core.config.plugins.PluginFactory;
+import org.apache.logging.log4j.core.lookup.StrSubstitutor;
 import org.apache.logging.log4j.status.StatusLogger;
 
 import java.io.File;
@@ -72,21 +75,24 @@ public class DefaultRolloverStrategy imp
     /**
      * Index for oldest retained log file.
      */
-    private int maxIndex;
+    private final int maxIndex;
 
     /**
      * Index for most recent log file.
      */
-    private int minIndex;
+    private final int minIndex;
+
+    private final StrSubstitutor subst;
 
     /**
      * Constructs a new instance.
      * @param min The minimum index.
      * @param max The maximum index.
      */
-    public DefaultRolloverStrategy(int min, int max) {
+    protected DefaultRolloverStrategy(int min, int max, StrSubstitutor subst) {
         minIndex = min;
         maxIndex = max;
+        this.subst = subst;
     }
 
     /**
@@ -107,7 +113,7 @@ public class DefaultRolloverStrategy imp
             manager.getProcessor().formatFileName(purgeStart, buf);
             String currentFileName = manager.getFileName();
 
-            String renameTo = buf.toString();
+            String renameTo = subst.replace(buf);
             String compressedName = renameTo;
             Action compressAction = null;
 
@@ -143,7 +149,7 @@ public class DefaultRolloverStrategy imp
         StringBuilder buf = new StringBuilder();
         manager.getProcessor().formatFileName(lowIndex, buf);
 
-        String lowFilename = buf.toString();
+        String lowFilename = subst.replace(buf);
 
         if (lowFilename.endsWith(".gz")) {
             suffixLength = 3;
@@ -188,7 +194,7 @@ public class DefaultRolloverStrategy imp
                 buf.setLength(0);
                 manager.getProcessor().formatFileName(i + 1, buf);
 
-                String highFilename = buf.toString();
+                String highFilename = subst.replace(buf);
                 String renameTo = highFilename;
 
                 if (isBase) {
@@ -230,11 +236,13 @@ public class DefaultRolloverStrategy imp
      * Create the DefaultRolloverStrategy.
      * @param max The maximum number of files to keep.
      * @param min The minimum number of files to keep.
+     * @param config The Configuration.
      * @return A DefaultRolloverStrategy.
      */
     @PluginFactory
     public static DefaultRolloverStrategy createStrategy(@PluginAttr("max") 
String max,
-                                                         @PluginAttr("min") 
String min) {
+                                                         @PluginAttr("min") 
String min,
+                                                         @PluginConfiguration 
Configuration config) {
 
         int minIndex;
         if (min != null) {
@@ -256,7 +264,7 @@ public class DefaultRolloverStrategy imp
         } else {
             maxIndex = DEFAULT_WINDOW_SIZE;
         }
-        return new DefaultRolloverStrategy(minIndex, maxIndex);
+        return new DefaultRolloverStrategy(minIndex, maxIndex, 
config.getSubst());
     }
 
 }

Copied: 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/DateLookup.java
 (from r1224872, 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/EnvironmentLookup.java)
URL: 
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/DateLookup.java?p2=logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/DateLookup.java&p1=logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/EnvironmentLookup.java&r1=1224872&r2=1225972&rev=1225972&view=diff
==============================================================================
--- 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/EnvironmentLookup.java
 (original)
+++ 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/DateLookup.java
 Fri Dec 30 23:53:24 2011
@@ -16,31 +16,53 @@
  */
 package org.apache.logging.log4j.core.lookup;
 
+import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.core.LogEvent;
 import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.status.StatusLogger;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 
 /**
- * Looks up keys from environment variables.
+ * Formats the current date or the date in the LogEvent. The "key" is used as 
the format String.
  */
-@Plugin(name = "env", type = "Lookup")
-public class EnvironmentLookup implements StrLookup {
+@Plugin(name = "date", type = "Lookup")
+public class DateLookup implements StrLookup {
 
+    private static final Logger LOGGER = StatusLogger.getLogger();
     /**
      * Get the value of the environment variable.
-     * @param key  the key to be looked up, may be null
+     * @param key the format to use. If null, the default DateFormat will be 
used.
      * @return The value of the environment variable.
      */
     public String lookup(String key) {
-        return System.getenv(key);
+        return formatDate(System.currentTimeMillis(), key);
     }
 
     /**
      * Get the value of the environment variable.
      * @param event The current LogEvent (is ignored by this StrLookup).
-     * @param key  the key to be looked up, may be null
+     * @param key the format to use. If null, the default DateFormat will be 
used.
      * @return The value of the environment variable.
      */
     public String lookup(LogEvent event, String key) {
-        return System.getenv(key);
+        return formatDate(event.getMillis(), key);
+    }
+
+    private String formatDate(long date, String format) {
+        DateFormat dateFormat = null;
+        if (format != null) {
+            try {
+                dateFormat = new SimpleDateFormat(format);
+            } catch (Exception ex) {
+                LOGGER.error("Invalid date format: \"" + format + "\", using 
default", ex);
+            }
+        }
+        if (dateFormat == null) {
+            dateFormat = DateFormat.getInstance();
+        }
+        return dateFormat.format(new Date(date));
     }
 }

Copied: 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/lookup/DateLookupTest.java
 (from r1220999, 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/lookup/EnvironmentLookupTest.java)
URL: 
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/lookup/DateLookupTest.java?p2=logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/lookup/DateLookupTest.java&p1=logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/lookup/EnvironmentLookupTest.java&r1=1220999&r2=1225972&rev=1225972&view=diff
==============================================================================
--- 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/lookup/EnvironmentLookupTest.java
 (original)
+++ 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/lookup/DateLookupTest.java
 Fri Dec 30 23:53:24 2011
@@ -16,25 +16,80 @@
  */
 package org.apache.logging.log4j.core.lookup;
 
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.Marker;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.message.Message;
 import org.junit.Test;
 
+import java.util.Calendar;
+import java.util.Map;
+import java.util.Stack;
+
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertEquals;
 
 /**
  *
  */
-public class EnvironmentLookupTest {
+public class DateLookupTest {
 
 
     @Test
     public void testLookup() {
-        StrLookup lookup = new EnvironmentLookup();
-        String value = lookup.lookup("PATH");
+        StrLookup lookup = new DateLookup();
+        LogEvent event = new MyLogEvent();
+        String value = lookup.lookup(event, "MM/dd/yyyy");
         assertNotNull(value);
-        value = lookup.lookup("BadKey");
-        assertNull(value);
+        assertEquals("12/30/2011", value);
+    }
+
+    private class MyLogEvent implements LogEvent {
+        public Level getLevel() {
+            return null;
+        }
+
+        public String getLoggerName() {
+            return null;
+        }
+
+        public StackTraceElement getSource() {
+            return null;
+        }
+
+        public Message getMessage() {
+            return null;
+        }
+
+        public Marker getMarker() {
+            return null;
+        }
+
+        public String getThreadName() {
+            return null;
+        }
+
+        public long getMillis() {
+            Calendar cal = Calendar.getInstance();
+            cal.set(2011, 11, 30, 10, 56, 35);
+            return cal.getTimeInMillis();
+        }
+
+        public Throwable getThrown() {
+            return null;
+        }
+
+        public Map<String, String> getContextMap() {
+            return null;
+        }
+
+        public Stack<String> getContextStack() {
+            return null;
+        }
+
+        public String getFQCN() {
+            return null;
+        }
     }
 }

Modified: 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-rolling1.xml
URL: 
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-rolling1.xml?rev=1225972&r1=1225971&r2=1225972&view=diff
==============================================================================
--- 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-rolling1.xml
 (original)
+++ 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-rolling1.xml
 Fri Dec 30 23:53:24 2011
@@ -26,7 +26,8 @@
     <Console name="STDOUT">
       <PatternLayout pattern="%m%n"/>
     </Console>
-    <RollingFile name="RollingFile" fileName="${filename}" 
filePattern="target/rolling1/test1-%i.log.gz">
+    <RollingFile name="RollingFile" fileName="${filename}"
+                 
filePattern="target/rolling1/test1-$${date:MM-dd-yyyy}-%i.log.gz">
       <PatternLayout>
         <pattern>%d %p %C{1.} [%t] %m%n</pattern>
       </PatternLayout>

Modified: 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/src/site/site.xml
URL: 
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/src/site/site.xml?rev=1225972&r1=1225971&r2=1225972&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/src/site/site.xml 
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/src/site/site.xml Fri 
Dec 30 23:53:24 2011
@@ -63,6 +63,7 @@
       </item>
       <item name="Lookups" href="/manual/lookups.html" collapse="true">
         <item name="ContextMap" href="/manual/lookups.html#ContextMapLookup"/>
+        <item name="Date" href="/manual/lookups.html#DateLookcup"/>
         <item name="Environment" 
href="/manual/lookups.html#EnvironmentLookup"/>
         <item name="Map" href="/manual/lookups.html#MapLookup"/>
         <item name="StructuredData" 
href="/manual/lookups.html#StructuredDataLookup"/>
@@ -77,7 +78,7 @@
         <item name="JSMTopic" href="/manual/appenders.html#JMSTopicAppender"/>
         <item name="OutputStream" 
href="/manual/appenders.html#OutputStreamAppender"/>
         <item name="Rewrite" href="/manual/appenders.html#RewriteAppender"/>
-        <item name="RollingFile" 
href="/manual/appenders.html#RollingFileappender"/>
+        <item name="RollingFile" 
href="/manual/appenders.html#RollingFileAppender"/>
         <item name="Routing" href="/manual/appenders.html#RoutingAppender"/>
         <item name="Socket" href="/manual/appenders.html#SocketAppender"/>
         <item name="Syslog" href="/manual/appenders.html#SyslogAppender"/>

Modified: 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/src/site/xdoc/manual/appenders.xml
URL: 
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/src/site/xdoc/manual/appenders.xml?rev=1225972&r1=1225971&r2=1225972&view=diff
==============================================================================
--- 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/src/site/xdoc/manual/appenders.xml
 (original)
+++ 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/src/site/xdoc/manual/appenders.xml
 Fri Dec 30 23:53:24 2011
@@ -45,6 +45,7 @@
         <p>
           Appenders always have a name so that they can be referenced from 
Loggers.
         </p>
+        <a name="ConsoleAppender"/>
         <subsection name="ConsoleAppender">
           <p>
             As one might expect, the ConsoleAppender writes its output to 
either System.err or System.out with System.err
@@ -105,6 +106,7 @@
   ]]></source>
           </p>
         </subsection>
+        <a name="FailoverAppender"/>
         <subsection name="FailoverAppender">
           <p>The FailoverAppender wraps a set of appenders. If the primary 
Appender fails the secondary appenders will be
           tried in order until one succeeds or there are no more secondaries 
to try.</p>
@@ -179,6 +181,7 @@
   ]]></source>
           </p>
         </subsection>
+        <a name="FileAppender"/>
         <subsection name="FileAppender">
           <p>The FileAppender is an OutputStreamAppender that writes to the 
File named in the fileName parameter. The
             FileAppender uses a FileManager (which extends 
OutputStreamManager) to actually perform the file I/O. While
@@ -272,6 +275,7 @@
   ]]></source>
           </p>
         </subsection>
+        <a name="FlumeAvroAppender"/>
         <subsection name="FlumeAvroAppender">
           <p><a href="http://incubator.apache.org/projects/flume.html";>Apache 
Flume</a> is a distributed, reliable,
             and available system for efficiently collecting, aggregating, and 
moving large amounts of log data
@@ -390,6 +394,7 @@
   ]]></source>
           </p>
         </subsection>
+        <a name="JMSQueueAppender"/>
         <subsection name="JMSQueueAppender">
           <p>The JMSQueueAppender sends the formatted log event to a JMS 
Queue.</p>
           <table border="1" width="100%">
@@ -497,6 +502,7 @@
   ]]></source>
           </p>
         </subsection>
+        <a name="JMSTopicAppender"/>
         <subsection name="JMSTopicAppender">
           <p>The JMSTopicAppender sends the formatted log event to a JMS 
Topic.</p>
           <table border="1" width="100%">
@@ -605,6 +611,7 @@
   ]]></source>
           </p>
         </subsection>
+        <a name="OutputStreamAppender"/>
         <subsection name="OutputStreamAppender">
           The OutputStreamAppender provides the base for many of the other 
Appenders such as the File and Socket
           appenders that write the event to an Output Stream. It cannot be 
directly configured. Support for
@@ -612,6 +619,7 @@
           OutputStreamManager to handle the actual I/O, allowing the stream to 
be shared by Appenders in multiple
           configurations.
         </subsection>
+        <a name="RewriteAppender"/>
         <subsection name="RewriteAppender">
           <p>
             The RewriteAppender allows the LogEvent to manipulated before it 
is processed by another Appender. This
@@ -707,6 +715,7 @@
   ]]></source>
           </p>
         </subsection>
+        <a name="RollingFileAppender"/>
         <subsection name="RollingFileAppender">
           <p>The RollingFileAppender is an OutputStreamAppender that writes to 
the File named in the fileName parameter
             and rolls the file over according the TriggeringPolicy and the 
RolloverPolicy. The
@@ -763,7 +772,9 @@
                 dependent on the RolloverPolicy that is used. The 
DefaultRolloverPolicy will accept both
                 a date/time pattern compatible with
                 <a 
href="http://download.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html";>SimpleDateFormat</a>
-                and and/or a %d which represents an integer counter.</td>
+                and and/or a %d which represents an integer counter. The 
pattern also supports interpolation at
+                runtime so any of the Lookups (such as the <a 
href="./lookups.html#DateLookup">DateLookup</a> can
+                be included in the pattern.</td>
             </tr>
             <tr>
               <td>immediateFlush</td>
@@ -833,7 +844,8 @@
                 it will be incremented on each rollover. If the pattern 
contains both a date/time and integer
                 in the pattern the integer will be incremented until the 
result of the date/time pattern changes. If
                 the file pattern ends with ".gz" or ".zip" the resulting 
archive will be compressed using the
-                compression scheme that matches the suffix.
+                compression scheme that matches the suffix. The pattern may 
also contain lookup references that
+                can be resolved at runtime such as is shown in the example 
below.
               </p>
               <table border="1" width="100%">
                 <tr>
@@ -856,13 +868,15 @@
               </table>
           <p>
             Below is a sample configuration that uses a RollingFileAppender 
with both the time and size based
-            triggering policies, will create up to 7 archives on the same day 
(1-7), and will compress each
+            triggering policies, will create up to 7 archives on the same day 
(1-7) that are stored in a directory
+            based on the current year and month, and will compress each
             archive using gzip:
 
             <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
 <configuration status="warn" name="MyApp" packages="">
   <appenders>
-    <RollingFile name="RollingFile" fileName="logs/app.log" 
filePattern="logs/app-%d{MM-dd-yyyy}-%d.log.gz">
+    <RollingFile name="RollingFile" fileName="logs/app.log"
+                                    
filePattern="logs/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%d.log.gz">
       <PatternLayout>
         <pattern>%d %p %C{1.} [%t] %m%n</pattern>
       </PatternLayout>
@@ -881,6 +895,7 @@
   ]]></source>
           </p>
         </subsection>
+        <a name="RoutingAppender"/>
         <subsection name="RoutingAppender">
            <p>
              The RoutingAppender evaluates LogEvents and then routes them to a 
subordinate Appender. The target
@@ -974,6 +989,7 @@
   ]]></source>
           </p>
         </subsection>
+        <a name="SocketAppender"/>
         <subsection name="SocketAppender">
           <p>
             The SocketAppender is an OutputStreamAppender that writes its 
output to a remote destination
@@ -1041,6 +1057,7 @@
             <caption align="top">SocketAppender Parameters</caption>
           </table>
         </subsection>
+        <a name="SyslogAppender"/>
         <subsection name="SyslogAppender">
           <p>
             The SyslogAppender is a SocketAppender that writes its output to a 
remote destination

Modified: 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/src/site/xdoc/manual/lookups.xml
URL: 
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/src/site/xdoc/manual/lookups.xml?rev=1225972&r1=1225971&r2=1225972&view=diff
==============================================================================
--- 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/src/site/xdoc/manual/lookups.xml
 (original)
+++ 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/src/site/xdoc/manual/lookups.xml
 Fri Dec 30 23:53:24 2011
@@ -48,6 +48,22 @@
       </PatternLayout>
     </File>]]></source>
         </subsection>
+        <a name="DateLookup"/>
+        <subsection name="DateLookup">
+          <p>
+            The DateLookup is somewhat unusual from the other lookups as it 
doesn't use the key to locate an item.
+            Instead, the key can be used to specify a date format string that 
is valid for
+            <a 
href="http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html";>SimpleDateFormat</a>.
+            The current date, or the date associated with the current log 
event will be formatted as specified.
+          </p>
+          <source><![CDATA[    <RollingFile name="Rolling-${map:type}" 
fileName="${filename}"
+                 
filePattern="target/rolling1/test1-$${date:MM-dd-yyyy}.%i.log.gz">
+      <PatternLayout>
+        <pattern>%d %p %C{1.} [%t] %m%n</pattern>
+      </PatternLayout>
+      <SizeBasedTriggeringPolicy size="500" />
+    </RollingFile>]]></source>
+        </subsection>
         <a name="EnvironmentLookup"/>
         <subsection name="EnvironmentLookup">
           <p>


Reply via email to