logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1405136 - in /logging/log4j/log4j2/trunk: core/src/main/java/org/apache/logging/log4j/core/pattern/DatePatternConverter.java src/site/xdoc/manual/layouts.xml
Date Fri, 02 Nov 2012 20:10:52 GMT
Author: ggregory
Date: Fri Nov  2 20:10:51 2012
New Revision: 1405136

URL: http://svn.apache.org/viewvc?rev=1405136&view=rev
Log:
Implement and document COMPACT date format.

Modified:
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/pattern/DatePatternConverter.java
    logging/log4j/log4j2/trunk/src/site/xdoc/manual/layouts.xml

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/pattern/DatePatternConverter.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/pattern/DatePatternConverter.java?rev=1405136&r1=1405135&r2=1405136&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/pattern/DatePatternConverter.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/pattern/DatePatternConverter.java
Fri Nov  2 20:10:51 2012
@@ -37,6 +37,11 @@ public final class DatePatternConverter 
     private static final String ABSOLUTE_FORMAT = "ABSOLUTE";
     
     /**
+     * COMPACT string literal.
+     */
+    private static final String COMPACT_FORMAT = "COMPACT";
+    
+    /**
      * SimpleTimePattern for ABSOLUTE.
      */
     private static final String ABSOLUTE_TIME_PATTERN = "HH:mm:ss,SSS";
@@ -72,6 +77,11 @@ public final class DatePatternConverter 
     private static final String ISO8601_BASIC_PATTERN = "yyyyMMdd HHmmss,SSS";
     
     /**
+     * SimpleTimePattern for COMPACT.
+     */
+    private static final String COMPACT_PATTERN = "yyyyMMddHHmmssSSS";
+    
+    /**
      * Date format.
      */
     private String cachedDate;
@@ -108,6 +118,8 @@ public final class DatePatternConverter 
             pattern = ABSOLUTE_TIME_PATTERN;
         } else if (patternOption.equalsIgnoreCase(DATE_AND_TIME_FORMAT)) {
             pattern = DATE_AND_TIME_PATTERN;
+        } else if (patternOption.equalsIgnoreCase(COMPACT_FORMAT)) {
+            pattern = COMPACT_PATTERN;
         } else {
             pattern = patternOption;
         }

Modified: logging/log4j/log4j2/trunk/src/site/xdoc/manual/layouts.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/site/xdoc/manual/layouts.xml?rev=1405136&r1=1405135&r2=1405136&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/site/xdoc/manual/layouts.xml (original)
+++ logging/log4j/log4j2/trunk/src/site/xdoc/manual/layouts.xml Fri Nov  2 20:10:51 2012
@@ -223,6 +223,7 @@ WARN  [main]: Message 2</pre>
                 </p>
                 <p>The predefined formats are
                   <em>ABSOLUTE</em>,
+                  <em>COMPACT</em>,
                   <em>DATE</em>,
                   <em>ISO8601</em>,
                   and
@@ -231,11 +232,7 @@ WARN  [main]: Message 2</pre>
                 <p>
                   You can also use a set of braces containing a time zone id per
                   <a href="http://docs.oracle.com/javase/6/docs/api/java/util/TimeZone.html#getTimeZone(java.lang.String)">
-                    java.util.TimeZone.getTimeZone</a>.
-                  For example, <b>%d{HH:mm:ss,SSS}</b>, <b>%d{dd&nbsp;MMM&nbsp;yyyy&nbsp;HH:mm:ss,SSS}</b>,
-                  <b>%d{DATE}</b>
-                  or<b>%d{HH:mm:ss}{GMT+0}</b>. If no date format specifier is
given then
-                  ISO8601 format is assumed.
+                    java.util.TimeZone.getTimeZone</a>. If no date format specifier
is given then ISO8601 format is assumed.
                   <table border="1" width="100%">
                     <tr>
                       <th>Pattern</th>
@@ -258,6 +255,10 @@ WARN  [main]: Message 2</pre>
                       <td>02 Nov 2012 14:34:02,781</td>
                     </tr>
                     <tr>
+                      <td>%d{COMPACT}</td>
+                      <td>20121102143402781</td>
+                    </tr>
+                    <tr>
                       <td>%d{HH:mm:ss,SSS}</td>
                       <td>14:34:02,781</td>
                     </tr>



Mime
View raw message