You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rg...@apache.org on 2015/10/11 23:06:11 UTC
[01/27] logging-log4j2 git commit: bugfix: use OS-independent line
separators to run on Windows also
Repository: logging-log4j2
Updated Branches:
refs/heads/LOG4J2-1136 fd5de4efc -> cda6fb61f
bugfix: use OS-independent line separators to run on Windows also
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/e4ad9851
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/e4ad9851
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/e4ad9851
Branch: refs/heads/LOG4J2-1136
Commit: e4ad98519d4e8d10de282d9dccdf26c6865cb7ca
Parents: fd5de4e
Author: rpopma <rp...@apache.org>
Authored: Thu Sep 24 15:18:03 2015 +0200
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Sun Oct 11 12:34:27 2015 -0700
----------------------------------------------------------------------
.../org/apache/logging/log4j/core/layout/PatternLayoutTest.java | 1 -
1 file changed, 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/e4ad9851/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java
index 53335d6..8cec03a 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java
@@ -255,7 +255,6 @@ public class PatternLayoutTest {
// System.out.println("event2=" + event2.getTimeMillis() / 1000);
}
- @SuppressWarnings("unused")
private void testUnixTime(final String pattern) throws Exception {
final PatternLayout layout = PatternLayout.newBuilder().withPattern(pattern + " %m")
.withConfiguration(ctx.getConfiguration()).build();
[06/27] logging-log4j2 git commit: LOG4J2-1126 change log entry for
web site corrections and updates
Posted by rg...@apache.org.
LOG4J2-1126 change log entry for web site corrections and updates
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/ab17f70a
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/ab17f70a
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/ab17f70a
Branch: refs/heads/LOG4J2-1136
Commit: ab17f70a464ad93d6abe10d9f1a70d8b7cb0b2bb
Parents: e8ccf2b
Author: rpopma <rp...@apache.org>
Authored: Mon Oct 5 00:17:36 2015 +0200
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Sun Oct 11 12:40:42 2015 -0700
----------------------------------------------------------------------
src/changes/changes.xml | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ab17f70a/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index c3004b6..65f3a12 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -63,6 +63,9 @@
<action issue="LOG4J2-1144" dev="ggregory" type="fix">
Add %markerSimpleName in pattern layout should evaluate to marker name (not toString()).
</action>
+ <action issue="LOG4J2-1126" dev="ggregory" type="fix">
+ Web site corrections and updates.
+ </action>
<action issue="LOG4J2-1040" dev="ggregory" type="update">
Update MongoDB driver from 2.13.3 to 3.0.4.
</action>
[18/27] logging-log4j2 git commit: LOG4J2-1149 fix another JUnit test
to give correct results if daylight savings apply
Posted by rg...@apache.org.
LOG4J2-1149 fix another JUnit test to give correct results if daylight
savings apply
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/5e246db5
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/5e246db5
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/5e246db5
Branch: refs/heads/LOG4J2-1136
Commit: 5e246db53458fc6ea26e47b07aba60f5189eef4e
Parents: 2b96742
Author: rpopma <rp...@apache.org>
Authored: Mon Oct 5 02:04:34 2015 +0200
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Sun Oct 11 12:40:43 2015 -0700
----------------------------------------------------------------------
.../logging/log4j/core/pattern/DatePatternConverterTest.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/5e246db5/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/DatePatternConverterTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/DatePatternConverterTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/DatePatternConverterTest.java
index 1bd70a9..5bd40df 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/DatePatternConverterTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/DatePatternConverterTest.java
@@ -76,7 +76,12 @@ public class DatePatternConverterTest {
final StringBuilder sb = new StringBuilder();
converter.format(event, sb);
- final String expected = "2011-12-30T09:56:35,987";
+ final TimeZone tz = TimeZone.getTimeZone("UTC");
+ final SimpleDateFormat sdf = new SimpleDateFormat(converter.getPattern());
+ sdf.setTimeZone(tz);
+ final long adjusted = event.getTimeMillis() + tz.getDSTSavings();
+ final String expected = sdf.format(new Date(adjusted));
+ // final String expected = "2011-12-30T09:56:35,987";
assertEquals(expected, sb.toString());
}
[07/27] logging-log4j2 git commit: LOG4J2-1140 Fixed bug where
headers were not being written to first file with RollingFileAppender.
Posted by rg...@apache.org.
LOG4J2-1140 Fixed bug where headers were not being written to first file
with RollingFileAppender.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/e8ccf2b1
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/e8ccf2b1
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/e8ccf2b1
Branch: refs/heads/LOG4J2-1136
Commit: e8ccf2b12732fff9c1dabd5b6ecc66ae8d7b6506
Parents: dbc5d43
Author: rpopma <rp...@apache.org>
Authored: Mon Oct 5 00:10:54 2015 +0200
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Sun Oct 11 12:40:42 2015 -0700
----------------------------------------------------------------------
.../logging/log4j/core/appender/rolling/RollingFileManager.java | 3 ++-
src/changes/changes.xml | 3 +++
2 files changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/e8ccf2b1/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java
index 72ee965..f53278f 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java
@@ -303,6 +303,8 @@ public class RollingFileManager extends FileManager {
if (null != parent && !parent.exists()) {
parent.mkdirs();
}
+ // LOG4J2-1140: check writeHeader before creating the file
+ final boolean writeHeader = !data.append || !file.exists();
try {
file.createNewFile();
} catch (final IOException ioe) {
@@ -311,7 +313,6 @@ public class RollingFileManager extends FileManager {
}
final long size = data.append ? file.length() : 0;
- final boolean writeHeader = !data.append || !file.exists();
OutputStream os;
try {
os = new FileOutputStream(name, data.append);
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/e8ccf2b1/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 7d18eaf..c3004b6 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -39,6 +39,9 @@
<action issue="LOG4J2-1020" dev="mikes" type="add">
Add possibility to set shutdown timeout on AsyncAppender.
</action>
+ <action issue="LOG4J2-1140" dev="rpopma" type="fix">
+ Fixed bug where headers were not being written to first file with RollingFileAppender.
+ </action>
<action issue="LOG4J2-1149" dev="rpopma" type="fix">
Fixed bug where PatternLayout predefined date pattern with time zone always renders default date format.
</action>
[12/27] logging-log4j2 git commit: LOG4J2-1151 fixes and documentation
Posted by rg...@apache.org.
LOG4J2-1151 fixes and documentation
- Mention on Layout manual page that specifying ISO-8859-1 charset can
improve performance
- cover both US-ASCII and ISO-8859-1
- Improve wording in change.xml
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/ce419dc1
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/ce419dc1
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/ce419dc1
Branch: refs/heads/LOG4J2-1136
Commit: ce419dc11453f26665b9f1963cd26aefa5cc6aad
Parents: d44bf68
Author: rpopma <rp...@apache.org>
Authored: Mon Oct 5 19:03:08 2015 +0200
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Sun Oct 11 12:40:43 2015 -0700
----------------------------------------------------------------------
.../log4j/core/layout/AbstractStringLayout.java | 23 ++++++++++++--------
src/changes/changes.xml | 2 +-
src/site/xdoc/manual/layouts.xml.vm | 5 +++++
3 files changed, 20 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce419dc1/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
index 0001b20..d48ee00 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
@@ -24,10 +24,13 @@ import org.apache.logging.log4j.core.LogEvent;
/**
* Abstract base class for Layouts that result in a String.
+ * <p>
+ * Since 2.4.1, this class has custom logic to convert ISO-8859-1 or US-ASCII Strings to byte[] arrays to improve
+ * performance: all characters are simply cast to bytes.
*/
/*
- * Implementation note: prefer String.getBytes(String) to String.getBytes(Charset) for performance reasons.
- * See https://issues.apache.org/jira/browse/LOG4J2-935 for details.
+ * Implementation note: prefer String.getBytes(String) to String.getBytes(Charset) for performance reasons. See
+ * https://issues.apache.org/jira/browse/LOG4J2-935 for details.
*/
public abstract class AbstractStringLayout extends AbstractLayout<String> {
@@ -35,7 +38,7 @@ public abstract class AbstractStringLayout extends AbstractLayout<String> {
* Default length for new StringBuilder instances: {@value} .
*/
protected static final int DEFAULT_STRING_BUILDER_SIZE = 1024;
-
+
private final static ThreadLocal<StringBuilder> threadLocal = new ThreadLocal<>();
private static final long serialVersionUID = 1L;
@@ -46,7 +49,7 @@ public abstract class AbstractStringLayout extends AbstractLayout<String> {
// TODO: Charset is not serializable. Implement read/writeObject() ?
private final Charset charset;
private final String charsetName;
- private final boolean isIso8859_1;
+ private final boolean isDirectSingleByteMapping;
protected AbstractStringLayout(final Charset charset) {
this(charset, null, null);
@@ -56,7 +59,8 @@ public abstract class AbstractStringLayout extends AbstractLayout<String> {
super(header, footer);
this.charset = charset == null ? StandardCharsets.UTF_8 : charset;
this.charsetName = this.charset.name();
- isIso8859_1 = StandardCharsets.ISO_8859_1.equals(charset);
+ isDirectSingleByteMapping = StandardCharsets.ISO_8859_1.equals(charset)
+ || StandardCharsets.US_ASCII.equals(charset);
}
/**
@@ -69,7 +73,7 @@ public abstract class AbstractStringLayout extends AbstractLayout<String> {
static byte[] toBytes(final String str, final Charset charset) {
if (str != null) {
if (StandardCharsets.ISO_8859_1.equals(charset)) {
- return customEncode(str);
+ return encodeSingleByteChars(str);
}
final Charset actual = charset != null ? charset : Charset.defaultCharset();
try { // LOG4J2-935: String.getBytes(String) gives better performance
@@ -97,8 +101,8 @@ public abstract class AbstractStringLayout extends AbstractLayout<String> {
}
protected byte[] getBytes(final String s) {
- if (isIso8859_1) { // rely on branch prediction to eliminate this check if false
- return customEncode(s);
+ if (isDirectSingleByteMapping) { // rely on branch prediction to eliminate this check if false
+ return encodeSingleByteChars(s);
}
try { // LOG4J2-935: String.getBytes(String) gives better performance
return s.getBytes(charsetName);
@@ -109,11 +113,12 @@ public abstract class AbstractStringLayout extends AbstractLayout<String> {
/**
* Encode the specified string by casting each character to a byte.
+ *
* @param s the string to encode
* @return the encoded String
* @see https://issues.apache.org/jira/browse/LOG4J2-1151
*/
- private static byte[] customEncode(String s) {
+ private static byte[] encodeSingleByteChars(String s) {
final int length = s.length();
final byte[] result = new byte[length];
for (int i = 0; i < length; i++) {
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce419dc1/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 7ad26f1..f7f5df1 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -67,7 +67,7 @@
Web site corrections and updates.
</action>
<action issue="LOG4J2-1151" dev="rpopma" type="update">
- Performance improvement: backport fast Java 8 String to byte[] encoder to AbstractStringLayout.
+ Performance improvement: backport Java 8 fast ISO-8859-1 String to byte[] encoder to AbstractStringLayout.
</action>
<action issue="LOG4J2-935" dev="rpopma" type="update">
Performance improvement when converting Strings to byte[] arrays.
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce419dc1/src/site/xdoc/manual/layouts.xml.vm
----------------------------------------------------------------------
diff --git a/src/site/xdoc/manual/layouts.xml.vm b/src/site/xdoc/manual/layouts.xml.vm
index ee1270a..6075b6a 100644
--- a/src/site/xdoc/manual/layouts.xml.vm
+++ b/src/site/xdoc/manual/layouts.xml.vm
@@ -49,6 +49,11 @@
where the default there is UTF-8. Each layout that extends <code>org.apache.logging.log4j.core.layout.AbstractStringLayout</code>
can provide its own default. See each layout below.
</p>
+ <p>
+ A custom character encoder was added to Log4j 2.4.1 for the ISO-8859-1 and US-ASCII charsets,
+ backporting the performance improvements from Java 8 for use on Java 7.
+ For applications that log only ISO-8859-1 characters, specifying this charset will improve performance.
+ </p>
<a name="CSVLayouts"/>
<subsection name="CSV Layouts">
<p>
[08/27] logging-log4j2 git commit: LOG4J2-1151 Performance
improvement: backport fast Java 8 String to byte[] encoder to
AbstractStringLayout.
Posted by rg...@apache.org.
LOG4J2-1151 Performance improvement: backport fast Java 8 String to
byte[] encoder to AbstractStringLayout.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/d44bf68d
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/d44bf68d
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/d44bf68d
Branch: refs/heads/LOG4J2-1136
Commit: d44bf68d81bcc8de3618f1dae98abbf70ed78bae
Parents: f3dee40
Author: rpopma <rp...@apache.org>
Authored: Mon Oct 5 15:21:51 2015 +0200
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Sun Oct 11 12:40:43 2015 -0700
----------------------------------------------------------------------
.../log4j/core/layout/AbstractStringLayout.java | 23 ++++++++++++++++++++
src/changes/changes.xml | 3 +++
2 files changed, 26 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/d44bf68d/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
index ae6f4c2..0001b20 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
@@ -46,6 +46,7 @@ public abstract class AbstractStringLayout extends AbstractLayout<String> {
// TODO: Charset is not serializable. Implement read/writeObject() ?
private final Charset charset;
private final String charsetName;
+ private final boolean isIso8859_1;
protected AbstractStringLayout(final Charset charset) {
this(charset, null, null);
@@ -55,6 +56,7 @@ public abstract class AbstractStringLayout extends AbstractLayout<String> {
super(header, footer);
this.charset = charset == null ? StandardCharsets.UTF_8 : charset;
this.charsetName = this.charset.name();
+ isIso8859_1 = StandardCharsets.ISO_8859_1.equals(charset);
}
/**
@@ -66,6 +68,9 @@ public abstract class AbstractStringLayout extends AbstractLayout<String> {
*/
static byte[] toBytes(final String str, final Charset charset) {
if (str != null) {
+ if (StandardCharsets.ISO_8859_1.equals(charset)) {
+ return customEncode(str);
+ }
final Charset actual = charset != null ? charset : Charset.defaultCharset();
try { // LOG4J2-935: String.getBytes(String) gives better performance
return str.getBytes(actual.name());
@@ -92,6 +97,9 @@ public abstract class AbstractStringLayout extends AbstractLayout<String> {
}
protected byte[] getBytes(final String s) {
+ if (isIso8859_1) { // rely on branch prediction to eliminate this check if false
+ return customEncode(s);
+ }
try { // LOG4J2-935: String.getBytes(String) gives better performance
return s.getBytes(charsetName);
} catch (UnsupportedEncodingException e) {
@@ -99,6 +107,21 @@ public abstract class AbstractStringLayout extends AbstractLayout<String> {
}
}
+ /**
+ * Encode the specified string by casting each character to a byte.
+ * @param s the string to encode
+ * @return the encoded String
+ * @see https://issues.apache.org/jira/browse/LOG4J2-1151
+ */
+ private static byte[] customEncode(String s) {
+ final int length = s.length();
+ final byte[] result = new byte[length];
+ for (int i = 0; i < length; i++) {
+ result[i] = (byte) s.charAt(i);
+ }
+ return result;
+ }
+
protected Charset getCharset() {
return charset;
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/d44bf68d/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 7195f1f..7ad26f1 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -66,6 +66,9 @@
<action issue="LOG4J2-1126" dev="ggregory" type="fix">
Web site corrections and updates.
</action>
+ <action issue="LOG4J2-1151" dev="rpopma" type="update">
+ Performance improvement: backport fast Java 8 String to byte[] encoder to AbstractStringLayout.
+ </action>
<action issue="LOG4J2-935" dev="rpopma" type="update">
Performance improvement when converting Strings to byte[] arrays.
</action>
[25/27] logging-log4j2 git commit: [maven-release-plugin] prepare for
next development iteration
Posted by rg...@apache.org.
[maven-release-plugin] prepare for next development iteration
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/6cd06f86
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/6cd06f86
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/6cd06f86
Branch: refs/heads/LOG4J2-1136
Commit: 6cd06f86f1c29778b5e68c3078676b6b5f61e7c9
Parents: b81e5c9
Author: rgoers <ra...@dslextreme.com>
Authored: Thu Oct 8 17:49:26 2015 -0700
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Sun Oct 11 12:40:44 2015 -0700
----------------------------------------------------------------------
log4j-1.2-api/pom.xml | 2 +-
log4j-api/pom.xml | 2 +-
log4j-bom/pom.xml | 4 ++--
log4j-core/pom.xml | 2 +-
log4j-distribution/pom.xml | 2 +-
log4j-flume-ng/pom.xml | 2 +-
log4j-iostreams/pom.xml | 2 +-
log4j-jcl/pom.xml | 2 +-
log4j-jmx-gui/pom.xml | 2 +-
log4j-jul/pom.xml | 2 +-
log4j-liquibase/pom.xml | 2 +-
log4j-nosql/pom.xml | 2 +-
log4j-perf/pom.xml | 2 +-
log4j-samples/configuration/pom.xml | 2 +-
log4j-samples/flume-common/pom.xml | 2 +-
log4j-samples/flume-embedded/pom.xml | 2 +-
log4j-samples/flume-remote/pom.xml | 2 +-
log4j-samples/loggerProperties/pom.xml | 2 +-
log4j-samples/pom.xml | 2 +-
log4j-slf4j-impl/pom.xml | 2 +-
log4j-taglib/pom.xml | 2 +-
log4j-to-slf4j/pom.xml | 2 +-
log4j-web/pom.xml | 2 +-
pom.xml | 4 ++--
24 files changed, 26 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/6cd06f86/log4j-1.2-api/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-1.2-api/pom.xml b/log4j-1.2-api/pom.xml
index 66af18a..2426e33 100644
--- a/log4j-1.2-api/pom.xml
+++ b/log4j-1.2-api/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId>
- <version>2.4.1</version>
+ <version>2.5-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<artifactId>log4j-1.2-api</artifactId>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/6cd06f86/log4j-api/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-api/pom.xml b/log4j-api/pom.xml
index 767a07c..c4cb7e9 100644
--- a/log4j-api/pom.xml
+++ b/log4j-api/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId>
- <version>2.4.1</version>
+ <version>2.5-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<artifactId>log4j-api</artifactId>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/6cd06f86/log4j-bom/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-bom/pom.xml b/log4j-bom/pom.xml
index 5a800f4..2c00427 100644
--- a/log4j-bom/pom.xml
+++ b/log4j-bom/pom.xml
@@ -26,7 +26,7 @@
<description>Apache Log4j Bill of Materials</description>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-bom</artifactId>
- <version>2.4.1</version>
+ <version>2.5-SNAPSHOT</version>
<packaging>pom</packaging>
<dependencyManagement>
<dependencies>
@@ -125,6 +125,6 @@
</build>
<scm>
- <tag>log4j-2.4.1</tag>
+ <tag>log4j-2.3</tag>
</scm>
</project>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/6cd06f86/log4j-core/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-core/pom.xml b/log4j-core/pom.xml
index d510a69..4545af7 100644
--- a/log4j-core/pom.xml
+++ b/log4j-core/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId>
- <version>2.4.1</version>
+ <version>2.5-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<artifactId>log4j-core</artifactId>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/6cd06f86/log4j-distribution/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-distribution/pom.xml b/log4j-distribution/pom.xml
index 85b7eed..d17286b 100644
--- a/log4j-distribution/pom.xml
+++ b/log4j-distribution/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId>
- <version>2.4.1</version>
+ <version>2.5-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<artifactId>log4j-distribution</artifactId>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/6cd06f86/log4j-flume-ng/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-flume-ng/pom.xml b/log4j-flume-ng/pom.xml
index c2805d3..f3c8097 100644
--- a/log4j-flume-ng/pom.xml
+++ b/log4j-flume-ng/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId>
- <version>2.4.1</version>
+ <version>2.5-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<artifactId>log4j-flume-ng</artifactId>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/6cd06f86/log4j-iostreams/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-iostreams/pom.xml b/log4j-iostreams/pom.xml
index 190b379..731c483 100644
--- a/log4j-iostreams/pom.xml
+++ b/log4j-iostreams/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId>
- <version>2.4.1</version>
+ <version>2.5-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<artifactId>log4j-iostreams</artifactId>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/6cd06f86/log4j-jcl/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-jcl/pom.xml b/log4j-jcl/pom.xml
index 1b297e1..87b68d0 100644
--- a/log4j-jcl/pom.xml
+++ b/log4j-jcl/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId>
- <version>2.4.1</version>
+ <version>2.5-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<artifactId>log4j-jcl</artifactId>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/6cd06f86/log4j-jmx-gui/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-jmx-gui/pom.xml b/log4j-jmx-gui/pom.xml
index 2b91b82..b907a7c 100644
--- a/log4j-jmx-gui/pom.xml
+++ b/log4j-jmx-gui/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId>
- <version>2.4.1</version>
+ <version>2.5-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<artifactId>log4j-jmx-gui</artifactId>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/6cd06f86/log4j-jul/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-jul/pom.xml b/log4j-jul/pom.xml
index 99b8cbd..718ac28 100644
--- a/log4j-jul/pom.xml
+++ b/log4j-jul/pom.xml
@@ -20,7 +20,7 @@
<parent>
<artifactId>log4j</artifactId>
<groupId>org.apache.logging.log4j</groupId>
- <version>2.4.1</version>
+ <version>2.5-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/6cd06f86/log4j-liquibase/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-liquibase/pom.xml b/log4j-liquibase/pom.xml
index e10d76b..e86b40e 100644
--- a/log4j-liquibase/pom.xml
+++ b/log4j-liquibase/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId>
- <version>2.4.1</version>
+ <version>2.5-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<artifactId>log4j-liquibase</artifactId>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/6cd06f86/log4j-nosql/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-nosql/pom.xml b/log4j-nosql/pom.xml
index be86211..fa132a5 100644
--- a/log4j-nosql/pom.xml
+++ b/log4j-nosql/pom.xml
@@ -20,7 +20,7 @@
<parent>
<artifactId>log4j</artifactId>
<groupId>org.apache.logging.log4j</groupId>
- <version>2.4.1</version>
+ <version>2.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/6cd06f86/log4j-perf/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-perf/pom.xml b/log4j-perf/pom.xml
index e2fa341..2528b02 100644
--- a/log4j-perf/pom.xml
+++ b/log4j-perf/pom.xml
@@ -20,7 +20,7 @@
<parent>
<artifactId>log4j</artifactId>
<groupId>org.apache.logging.log4j</groupId>
- <version>2.4.1</version>
+ <version>2.5-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/6cd06f86/log4j-samples/configuration/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-samples/configuration/pom.xml b/log4j-samples/configuration/pom.xml
index 7a0f25a..ce1f8e5 100644
--- a/log4j-samples/configuration/pom.xml
+++ b/log4j-samples/configuration/pom.xml
@@ -20,7 +20,7 @@
<parent>
<artifactId>log4j-samples</artifactId>
<groupId>org.apache.logging.log4j.samples</groupId>
- <version>2.4.1</version>
+ <version>2.5-SNAPSHOT</version>
</parent>
<artifactId>log4j-samples-configuration</artifactId>
<packaging>jar</packaging>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/6cd06f86/log4j-samples/flume-common/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-samples/flume-common/pom.xml b/log4j-samples/flume-common/pom.xml
index af5ff3d..3c177df 100644
--- a/log4j-samples/flume-common/pom.xml
+++ b/log4j-samples/flume-common/pom.xml
@@ -20,7 +20,7 @@
<parent>
<artifactId>log4j-samples</artifactId>
<groupId>org.apache.logging.log4j.samples</groupId>
- <version>2.4.1</version>
+ <version>2.5-SNAPSHOT</version>
</parent>
<artifactId>log4j-samples-flume-common</artifactId>
<packaging>jar</packaging>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/6cd06f86/log4j-samples/flume-embedded/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-samples/flume-embedded/pom.xml b/log4j-samples/flume-embedded/pom.xml
index e848d9c..528a3db 100644
--- a/log4j-samples/flume-embedded/pom.xml
+++ b/log4j-samples/flume-embedded/pom.xml
@@ -20,7 +20,7 @@
<parent>
<artifactId>log4j-samples</artifactId>
<groupId>org.apache.logging.log4j.samples</groupId>
- <version>2.4.1</version>
+ <version>2.5-SNAPSHOT</version>
</parent>
<artifactId>log4j-samples-flume-embedded</artifactId>
<packaging>war</packaging>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/6cd06f86/log4j-samples/flume-remote/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-samples/flume-remote/pom.xml b/log4j-samples/flume-remote/pom.xml
index 6876e90..4f8f494 100644
--- a/log4j-samples/flume-remote/pom.xml
+++ b/log4j-samples/flume-remote/pom.xml
@@ -20,7 +20,7 @@
<parent>
<artifactId>log4j-samples</artifactId>
<groupId>org.apache.logging.log4j.samples</groupId>
- <version>2.4.1</version>
+ <version>2.5-SNAPSHOT</version>
</parent>
<artifactId>log4j-samples-flume-remote</artifactId>
<packaging>war</packaging>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/6cd06f86/log4j-samples/loggerProperties/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-samples/loggerProperties/pom.xml b/log4j-samples/loggerProperties/pom.xml
index 6e28887..2bdbc6b 100644
--- a/log4j-samples/loggerProperties/pom.xml
+++ b/log4j-samples/loggerProperties/pom.xml
@@ -20,7 +20,7 @@
<parent>
<artifactId>log4j-samples</artifactId>
<groupId>org.apache.logging.log4j.samples</groupId>
- <version>2.4.1</version>
+ <version>2.5-SNAPSHOT</version>
</parent>
<artifactId>log4j-samples-loggerProperties</artifactId>
<packaging>jar</packaging>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/6cd06f86/log4j-samples/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-samples/pom.xml b/log4j-samples/pom.xml
index 178fd67..2e411a9 100644
--- a/log4j-samples/pom.xml
+++ b/log4j-samples/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId>
- <version>2.4.1</version>
+ <version>2.5-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<groupId>org.apache.logging.log4j.samples</groupId>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/6cd06f86/log4j-slf4j-impl/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-slf4j-impl/pom.xml b/log4j-slf4j-impl/pom.xml
index 12ce869..fa0a1ca 100644
--- a/log4j-slf4j-impl/pom.xml
+++ b/log4j-slf4j-impl/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId>
- <version>2.4.1</version>
+ <version>2.5-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<artifactId>log4j-slf4j-impl</artifactId>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/6cd06f86/log4j-taglib/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-taglib/pom.xml b/log4j-taglib/pom.xml
index e12a16b..62bc10d 100644
--- a/log4j-taglib/pom.xml
+++ b/log4j-taglib/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId>
- <version>2.4.1</version>
+ <version>2.5-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<artifactId>log4j-taglib</artifactId>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/6cd06f86/log4j-to-slf4j/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml
index cb43e53..a0b598b 100644
--- a/log4j-to-slf4j/pom.xml
+++ b/log4j-to-slf4j/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId>
- <version>2.4.1</version>
+ <version>2.5-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<artifactId>log4j-to-slf4j</artifactId>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/6cd06f86/log4j-web/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-web/pom.xml b/log4j-web/pom.xml
index 3c885b8..bfd2c09 100644
--- a/log4j-web/pom.xml
+++ b/log4j-web/pom.xml
@@ -20,7 +20,7 @@
<parent>
<artifactId>log4j</artifactId>
<groupId>org.apache.logging.log4j</groupId>
- <version>2.4.1</version>
+ <version>2.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/6cd06f86/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 95cd651..914d06f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
<artifactId>log4j</artifactId>
<packaging>pom</packaging>
<name>Apache Log4j 2</name>
- <version>2.4.1</version>
+ <version>2.5-SNAPSHOT</version>
<parent>
<groupId>org.apache</groupId>
<artifactId>apache</artifactId>
@@ -155,7 +155,7 @@
<connection>scm:git:http://git-wip-us.apache.org/repos/asf/logging-log4j2.git</connection>
<developerConnection>scm:git:https://git-wip-us.apache.org/repos/asf/logging-log4j2.git</developerConnection>
<url>https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;a=summary</url>
- <tag>log4j-2.4.1</tag>
+ <tag>log4j-2.3</tag>
</scm>
<organization>
<name>Apache Software Foundation</name>
[16/27] logging-log4j2 git commit: Use built-in UTF-8 Charset.
Posted by rg...@apache.org.
Use built-in UTF-8 Charset.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/4bc743ea
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/4bc743ea
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/4bc743ea
Branch: refs/heads/LOG4J2-1136
Commit: 4bc743eaa373ce4950cb0f3468a264233d829420
Parents: 6f57c58
Author: ggregory <gg...@apache.org>
Authored: Mon Oct 5 12:03:17 2015 -0700
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Sun Oct 11 12:40:43 2015 -0700
----------------------------------------------------------------------
.../logging/log4j/taglib/DumpTagTest.java | 243 ++++++++++---------
1 file changed, 122 insertions(+), 121 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/4bc743ea/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/DumpTagTest.java
----------------------------------------------------------------------
diff --git a/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/DumpTagTest.java b/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/DumpTagTest.java
index 7ab075c..7d28954 100644
--- a/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/DumpTagTest.java
+++ b/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/DumpTagTest.java
@@ -1,121 +1,122 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.taglib;
-
-import java.io.ByteArrayOutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.nio.charset.Charset;
-
-import javax.servlet.jsp.JspWriter;
-import javax.servlet.jsp.PageContext;
-import javax.servlet.jsp.tagext.Tag;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.springframework.mock.web.MockJspWriter;
-import org.springframework.mock.web.MockPageContext;
-
-import static org.junit.Assert.*;
-
-/**
- *
- */
-public class DumpTagTest {
- private static final Charset UTF8 = Charset.forName("UTF-8");
- private Writer writer;
- private ByteArrayOutputStream output;
- private MockPageContext context;
- private DumpTag tag;
-
- @Before
- public void setUp() {
- this.output = new ByteArrayOutputStream();
- this.writer = new OutputStreamWriter(this.output, UTF8);
-
- this.context = new MockPageContext() {
- private final MockJspWriter jspWriter = new MockJspWriter(writer);
- @Override
- public JspWriter getOut() {
- return this.jspWriter;
- }
- };
-
- this.tag = new DumpTag();
- this.tag.setPageContext(this.context);
- }
-
- @Test
- public void testDoEndTagDefaultPageScopeNoAttributes() throws Exception {
- final int returnValue = this.tag.doEndTag();
- assertEquals("The return value is not correct.", Tag.EVAL_PAGE, returnValue);
-
- this.writer.flush();
- final String output = new String(this.output.toByteArray(), UTF8);
- assertEquals("The output is not correct.", "<dl></dl>", output);
- }
-
- @Test
- public void testDoEndTagDefaultPageScope() throws Exception {
- this.context.setAttribute("testAttribute01", "testValue01", PageContext.PAGE_SCOPE);
- this.context.setAttribute("anotherAttribute02", "finalValue02", PageContext.PAGE_SCOPE);
- this.context.setAttribute("badAttribute03", "skippedValue03", PageContext.SESSION_SCOPE);
-
- final int returnValue = this.tag.doEndTag();
- assertEquals("The return value is not correct.", Tag.EVAL_PAGE, returnValue);
-
- this.writer.flush();
- final String output = new String(this.output.toByteArray(), UTF8);
- assertEquals("The output is not correct.",
- "<dl>" +
- "<dt><code>testAttribute01</code></dt><dd><code>testValue01</code></dd>" +
- "<dt><code>anotherAttribute02</code></dt><dd><code>finalValue02</code></dd>" +
- "</dl>", output);
- }
-
- @Test
- public void testDoEndTagSessionScopeNoAttributes() throws Exception {
- this.context.setAttribute("badAttribute01", "skippedValue01", PageContext.PAGE_SCOPE);
-
- this.tag.setScope("session");
- final int returnValue = this.tag.doEndTag();
- assertEquals("The return value is not correct.", Tag.EVAL_PAGE, returnValue);
-
- this.writer.flush();
- final String output = new String(this.output.toByteArray(), UTF8);
- assertEquals("The output is not correct.", "<dl></dl>", output);
- }
-
- @Test
- public void testDoEndTagSessionScope() throws Exception {
- this.context.setAttribute("otherAttribute03", "lostValue03", PageContext.PAGE_SCOPE);
- this.context.setAttribute("coolAttribute01", "weirdValue01", PageContext.SESSION_SCOPE);
- this.context.setAttribute("testAttribute02", "testValue02", PageContext.SESSION_SCOPE);
-
- this.tag.setScope("session");
- final int returnValue = this.tag.doEndTag();
- assertEquals("The return value is not correct.", Tag.EVAL_PAGE, returnValue);
-
- this.writer.flush();
- final String output = new String(this.output.toByteArray(), UTF8);
- assertEquals("The output is not correct.",
- "<dl>" +
- "<dt><code>coolAttribute01</code></dt><dd><code>weirdValue01</code></dd>" +
- "<dt><code>testAttribute02</code></dt><dd><code>testValue02</code></dd>" +
- "</dl>", output);
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.taglib;
+
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+
+import javax.servlet.jsp.JspWriter;
+import javax.servlet.jsp.PageContext;
+import javax.servlet.jsp.tagext.Tag;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.mock.web.MockJspWriter;
+import org.springframework.mock.web.MockPageContext;
+
+import static org.junit.Assert.*;
+
+/**
+ *
+ */
+public class DumpTagTest {
+ private static final Charset UTF8 = StandardCharsets.UTF_8;
+ private Writer writer;
+ private ByteArrayOutputStream output;
+ private MockPageContext context;
+ private DumpTag tag;
+
+ @Before
+ public void setUp() {
+ this.output = new ByteArrayOutputStream();
+ this.writer = new OutputStreamWriter(this.output, UTF8);
+
+ this.context = new MockPageContext() {
+ private final MockJspWriter jspWriter = new MockJspWriter(writer);
+ @Override
+ public JspWriter getOut() {
+ return this.jspWriter;
+ }
+ };
+
+ this.tag = new DumpTag();
+ this.tag.setPageContext(this.context);
+ }
+
+ @Test
+ public void testDoEndTagDefaultPageScopeNoAttributes() throws Exception {
+ final int returnValue = this.tag.doEndTag();
+ assertEquals("The return value is not correct.", Tag.EVAL_PAGE, returnValue);
+
+ this.writer.flush();
+ final String output = new String(this.output.toByteArray(), UTF8);
+ assertEquals("The output is not correct.", "<dl></dl>", output);
+ }
+
+ @Test
+ public void testDoEndTagDefaultPageScope() throws Exception {
+ this.context.setAttribute("testAttribute01", "testValue01", PageContext.PAGE_SCOPE);
+ this.context.setAttribute("anotherAttribute02", "finalValue02", PageContext.PAGE_SCOPE);
+ this.context.setAttribute("badAttribute03", "skippedValue03", PageContext.SESSION_SCOPE);
+
+ final int returnValue = this.tag.doEndTag();
+ assertEquals("The return value is not correct.", Tag.EVAL_PAGE, returnValue);
+
+ this.writer.flush();
+ final String output = new String(this.output.toByteArray(), UTF8);
+ assertEquals("The output is not correct.",
+ "<dl>" +
+ "<dt><code>testAttribute01</code></dt><dd><code>testValue01</code></dd>" +
+ "<dt><code>anotherAttribute02</code></dt><dd><code>finalValue02</code></dd>" +
+ "</dl>", output);
+ }
+
+ @Test
+ public void testDoEndTagSessionScopeNoAttributes() throws Exception {
+ this.context.setAttribute("badAttribute01", "skippedValue01", PageContext.PAGE_SCOPE);
+
+ this.tag.setScope("session");
+ final int returnValue = this.tag.doEndTag();
+ assertEquals("The return value is not correct.", Tag.EVAL_PAGE, returnValue);
+
+ this.writer.flush();
+ final String output = new String(this.output.toByteArray(), UTF8);
+ assertEquals("The output is not correct.", "<dl></dl>", output);
+ }
+
+ @Test
+ public void testDoEndTagSessionScope() throws Exception {
+ this.context.setAttribute("otherAttribute03", "lostValue03", PageContext.PAGE_SCOPE);
+ this.context.setAttribute("coolAttribute01", "weirdValue01", PageContext.SESSION_SCOPE);
+ this.context.setAttribute("testAttribute02", "testValue02", PageContext.SESSION_SCOPE);
+
+ this.tag.setScope("session");
+ final int returnValue = this.tag.doEndTag();
+ assertEquals("The return value is not correct.", Tag.EVAL_PAGE, returnValue);
+
+ this.writer.flush();
+ final String output = new String(this.output.toByteArray(), UTF8);
+ assertEquals("The output is not correct.",
+ "<dl>" +
+ "<dt><code>coolAttribute01</code></dt><dd><code>weirdValue01</code></dd>" +
+ "<dt><code>testAttribute02</code></dt><dd><code>testValue02</code></dd>" +
+ "</dl>", output);
+ }
+}
[24/27] logging-log4j2 git commit: LOG4J2-783 code cleanup: removed
old/misleading reference to UTF-8 charset
Posted by rg...@apache.org.
LOG4J2-783 code cleanup: removed old/misleading reference to UTF-8
charset
PatternLayout should and does use the platform default charset. The
createLayout() factory method specified UTF-8 as the default charset,
which is misleading and confusing for developers, so I removed the
default and added a comment.
This was not a real problem because XmlConfiguration uses
PatternLayout.Builder and not the factory method, so in reality the
platform default charset was correctly being used if no charset is
specified.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/c539c173
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/c539c173
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/c539c173
Branch: refs/heads/LOG4J2-1136
Commit: c539c17374ae4db612477e133ac59f7b1bf75fb1
Parents: 3ca1bfd
Author: rpopma <rp...@apache.org>
Authored: Tue Oct 6 15:21:47 2015 +0200
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Sun Oct 11 12:40:44 2015 -0700
----------------------------------------------------------------------
.../apache/logging/log4j/core/layout/PatternLayout.java | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c539c173/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java
index 9874af0..6c57820 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java
@@ -238,7 +238,7 @@ public final class PatternLayout extends AbstractStringLayout {
* @param replace
* A Regex replacement String.
* @param charset
- * The character set.
+ * The character set. The platform default is used if not specified.
* @param alwaysWriteExceptions
* If {@code "true"} (default) exceptions are always written even if the pattern contains no exception tokens.
* @param noConsoleNoAnsi
@@ -255,7 +255,8 @@ public final class PatternLayout extends AbstractStringLayout {
@PluginElement("PatternSelector") final PatternSelector patternSelector,
@PluginConfiguration final Configuration config,
@PluginElement("Replace") final RegexReplacement replace,
- @PluginAttribute(value = "charset", defaultString = "UTF-8") final Charset charset,
+ // LOG4J2-783 use platform default by default, so do not specify defaultString for charset
+ @PluginAttribute(value = "charset") final Charset charset,
@PluginAttribute(value = "alwaysWriteExceptions", defaultBoolean = true) final boolean alwaysWriteExceptions,
@PluginAttribute(value = "noConsoleNoAnsi", defaultBoolean = false) final boolean noConsoleNoAnsi,
@PluginAttribute("header") final String header,
@@ -395,7 +396,10 @@ public final class PatternLayout extends AbstractStringLayout {
}
public Builder withCharset(final Charset charset) {
- this.charset = charset;
+ // LOG4J2-783 if null, use platform default by default
+ if (charset != null) {
+ this.charset = charset;
+ }
return this;
}
[27/27] logging-log4j2 git commit: LOG4J2-1136 Add documentation on
Scripts
Posted by rg...@apache.org.
LOG4J2-1136 Add documentation on Scripts
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/cda6fb61
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/cda6fb61
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/cda6fb61
Branch: refs/heads/LOG4J2-1136
Commit: cda6fb61f3429f05ee5bdc1e8607974849b8a8d0
Parents: 6cd06f8
Author: Ralph Goers <rg...@nextiva.com>
Authored: Sun Oct 11 12:30:33 2015 -0700
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Sun Oct 11 12:44:19 2015 -0700
----------------------------------------------------------------------
src/site/site.xml | 2 +-
src/site/xdoc/manual/configuration.xml.vm | 79 +++++++++++++++++++++++---
src/site/xdoc/manual/filters.xml | 37 +++++++++++-
src/site/xdoc/manual/layouts.xml.vm | 55 +++++++++++++++++-
4 files changed, 159 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/cda6fb61/src/site/site.xml
----------------------------------------------------------------------
diff --git a/src/site/site.xml b/src/site/site.xml
index 8c076fa..0618a01 100644
--- a/src/site/site.xml
+++ b/src/site/site.xml
@@ -72,7 +72,7 @@
<item name="Configuring Appenders" href="/manual/configuration.html#Appenders"/>
<item name="Configuring Filters" href="/manual/configuration.html#Filters"/>
<item name="Property Substitution" href="/manual/configuration.html#PropertySubstitution"/>
- <item name-"Scripts" href="/manual/configuration.html#Scripts"/>
+ <item name="Scripts" href="/manual/configuration.html#Scripts"/>
<item name="XInclude" href="/manual/configuration.html#XInclude"/>
<item name="Status Messages" href="/manual/configuration.html#StatusMessages"/>
<item name="Unit Testing in Maven" href="/manual/configuration.html#UnitTestingInMaven"/>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/cda6fb61/src/site/xdoc/manual/configuration.xml.vm
----------------------------------------------------------------------
diff --git a/src/site/xdoc/manual/configuration.xml.vm b/src/site/xdoc/manual/configuration.xml.vm
index f9283ff..44d1491 100644
--- a/src/site/xdoc/manual/configuration.xml.vm
+++ b/src/site/xdoc/manual/configuration.xml.vm
@@ -1051,16 +1051,77 @@ rootLogger.appenderRef.stdout.ref = STDOUT
JSR 223 scripting framework and only require that the jars for that language be installed.
</p>
<p>
- The components that support using scripts do so by allowing a <script> element to be configured on
+ The components that support using scripts do so by allowing a <script>, <scriptFile>, or
+ <scriptRef> element to be configured on
them. The script element contains a name for the script, the language of the script, and the script text.
+ The scriptFile element contains the name of the script, its location, its language, its charset, and
+ whether the file should be watched for changes. The scriptRef element contains the name of the
+ script that is defined in the <scripts> configuration element.
The name of the script is used to store the script, along with its ScriptEngine, so it can quickly be
located each time the script needs to be run. While the name is not required, providing it will help in
- debugging problems when the script is running. The language must be provided and must specify one of
- the language names that appear in the Configuration status log as described in the next section.
+ debugging problems when the script is running. The language must be provided on the script element and must
+ specify one of the language names that appear in the Configuration status log as described in the next
+ section. If the language is not specified on the scriptFile element the language will be determined by
+ the file extension of the script path. If file monitoring is requested it will only be enabled if
+ a non-zero monitorInterval is specified on the configuration element. That interval will be used to
+ check for changes in the file.
</p>
+ <pre class="prettyprint linenums"><![CDATA[
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration status="debug" name="RoutingTest">
+ <Scripts>
+ <Script name="selector" language="javascript"><![CDATA[
+ var result;
+ if (logEvent.getLoggerName().equals("JavascriptNoLocation")) {
+ result = "NoLocation";
+ } else if (logEvent.getMarker() != null && logEvent.getMarker().isInstanceOf("FLOW")) {
+ result = "Flow";
+ }
+ result;
+ ]]]]><![CDATA[></Script>
+ <ScriptFile name="groovy.filter" path="scripts/filter.groovy"/>
+ </Scripts>
+
+ <Appenders>
+ <Console name="STDOUT">
+ <ScriptPatternSelector defaultPattern="%d %p %m%n">
+ <ScriptRef ref="selector"/>
+ <PatternMatch key="NoLocation" pattern="[%-5level] %c{1.} %msg%n"/>
+ <PatternMatch key="Flow" pattern="[%-5level] %c{1.} ====== %C{1.}.%M:%L %msg ======%n"/>
+ </ScriptPatternSelector>
+ <PatternLayout pattern="%m%n"/>
+ </Console>
+ </Appenders>
+
+ <Loggers>
+ <Logger name="EventLogger" level="info" additivity="false">
+ <ScriptFilter onMatch="ACCEPT" onMisMatch="DENY">
+ <Script name="GroovyFilter" language="groovy"><![CDATA[
+ if (logEvent.getMarker() != null && logEvent.getMarker().isInstanceOf("FLOW")) {
+ return true;
+ } else if (logEvent.getContextMap().containsKey("UserId")) {
+ return true;
+ }
+ return false;
+ ]]]]><![CDATA[>
+ </Script>
+ </ScriptFilter>
+ <AppenderRef ref="STDOUT"/>
+ </Logger>
+
+ <Root level="error">
+ <ScriptFilter onMatch="ACCEPT" onMisMatch="DENY">
+ <ScriptRef ref="groovy.filter"/>
+ </ScriptFilter>
+ <AppenderRef ref="STDOUT"/>
+ </Root>
+ </Loggers>
+
+</Configuration>]]>
+ </pre>
<p>
If the status attribute on the Configuration element is set to DEBUG the list of script engines currently
- installed and their attributes will be listed. Although some engines may say they are not thread safe
+ installed and their attributes will be listed. Although some engines may say they are not thread safe,
Log4j takes steps to insure that the scripts will run in a thread-safe manner if the engine advertises
that it is not thread safe.
</p>
@@ -1082,12 +1143,12 @@ rootLogger.appenderRef.stdout.ref = STDOUT
</p>
<p>
The components that support scripting expect a return value to be passed back to the calling Java code.
- This is not a problem for several of the scripting languages. However, Javascript does not allow a
+ This is not a problem for several of the scripting languages, but Javascript does not allow a
return statement unless it is within a function. However, Javascript will return the value of the last
statement executed in the script. As a consequence, code such as that shown below will result in the
desired behavior.
</p>
- <pre>
+ <pre><![CDATA[
var result;
if (logEvent.getLoggerName().equals("JavascriptNoLocation")) {
result = "NoLocation";
@@ -1095,7 +1156,7 @@ rootLogger.appenderRef.stdout.ref = STDOUT
result = "Flow";
}
result;
- </pre>
+ ]]></pre>
<h4>A special note on Beanshell</h4>
<p>
JSR 223 scripting engines are supposed to identify that they support the Compilable interface if they
@@ -1104,14 +1165,14 @@ rootLogger.appenderRef.stdout.ref = STDOUT
Beanshell script when it tries to compile them. All Beanshell scripts will then be interpreted on each
execution.
</p>
- <pre>
+ <pre><![CDATA[
2015-09-27 16:13:23,095 main DEBUG Script BeanShellSelector is compilable
2015-09-27 16:13:23,096 main WARN Error compiling script java.lang.Error: unimplemented
at bsh.engine.BshScriptEngine.compile(BshScriptEngine.java:175)
at bsh.engine.BshScriptEngine.compile(BshScriptEngine.java:154)
at org.apache.logging.log4j.core.script.ScriptManager$MainScriptRunner.<init>(ScriptManager.java:125)
at org.apache.logging.log4j.core.script.ScriptManager.addScript(ScriptManager.java:94)
- </pre>
+ ]]></pre>
</subsection>
<a name="XInclude"/>
<subsection name="XInclude">
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/cda6fb61/src/site/xdoc/manual/filters.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/manual/filters.xml b/src/site/xdoc/manual/filters.xml
index d5b1252..15db5f0 100644
--- a/src/site/xdoc/manual/filters.xml
+++ b/src/site/xdoc/manual/filters.xml
@@ -475,7 +475,7 @@
</tr>
<tr>
<td>script</td>
- <td>Script</td>
+ <td>Scriptm, ScriptFile or ScriptRef</td>
<td>The Script element that specifies the logic to be executed.
</td>
</tr>
@@ -548,6 +548,41 @@
<td>The StrSubstitutor used to replace lookup variables.</td>
</tr>
</table>
+ <p>
+ The sample below shows how to declare script fiels and then reference them in specific components.
+ </p>
+ <pre class="prettyprint linenums"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+<Configuration status="ERROR">
+ <Scripts>
+ <ScriptFile name="filter.js" language="JavaScript" path="src/test/resources/scripts/filter.js" charset="UTF-8" />
+ <ScriptFile name="filter.groovy" path="src/test/resources/scripts/filter.groovy" charset="UTF-8" />
+ </Scripts>
+ <Appenders>
+ <List name="List">
+ <PatternLayout pattern="[%-5level] %c{1.} %msg%n"/>
+ </List>
+ </Appenders>
+ <Loggers>
+ <Logger name="TestJavaScriptFilter" level="trace" additivity="false">
+ <AppenderRef ref="List">
+ <ScriptFilter onMatch="ACCEPT" onMisMatch="DENY">
+ <ScriptRef ref="filter.js" />
+ </ScriptFilter>
+ </AppenderRef>
+ </Logger>
+ <Logger name="TestGroovyFilter" level="trace" additivity="false">
+ <AppenderRef ref="List">
+ <ScriptFilter onMatch="ACCEPT" onMisMatch="DENY">
+ <ScriptRef ref="filter.groovy" />
+ </ScriptFilter>
+ </AppenderRef>
+ </Logger>
+ <Root level="trace">
+ <AppenderRef ref="List" />
+ </Root>
+ </Loggers>
+</Configuration>
+ ]]></pre>pre>
</subsection>
<a name="StructuredDataFilter"/>
<subsection name="StructuredDataFilter">
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/cda6fb61/src/site/xdoc/manual/layouts.xml.vm
----------------------------------------------------------------------
diff --git a/src/site/xdoc/manual/layouts.xml.vm b/src/site/xdoc/manual/layouts.xml.vm
index e29de73..47170ea 100644
--- a/src/site/xdoc/manual/layouts.xml.vm
+++ b/src/site/xdoc/manual/layouts.xml.vm
@@ -407,7 +407,14 @@ WARN [main]: Message 2</pre>
<tr>
<td>pattern</td>
<td>String</td>
- <td>A composite pattern string of one or more conversion patterns from the table below.</td>
+ <td>A composite pattern string of one or more conversion patterns from the table below. Cannot be
+ specified with a PatternSelector.</td>
+ </tr>
+ <tr>
+ <td>patternSelector</td>
+ <td>PatternSelector</td>
+ <td>A component that analyzes information in the LogEvent and determines which pattern should be
+ used to format the event. The pattern and patternSelector parameters are mutually exclusive.</td>
</tr>
<tr>
<td>replace</td>
@@ -557,7 +564,7 @@ WARN [main]: Message 2</pre>
</p>
<p>You can also use a set of braces containing a time zone id per
<a class="javadoc" href="${javadocRoot}/java/util/TimeZone.html${sharp}getTimeZone(java.lang.String)">
- java.util.TimeZone.getTimeZone</a>. If no date format specifier is given then the DEFAULT format is used.
+ java.util.TimeZone.getTimeZone</a>. If no date format specifier is given then ISO8601 format is assumed.
<table>
<tr>
<th>Pattern</th>
@@ -1472,7 +1479,49 @@ at org.apache.logging.log4j.core.pattern.ExtendedThrowableTest.testException(Ext
<pre class="prettyprint linenums"><![CDATA[<PatternLayout>
<pattern>%d %highlight{%p} %style{%C{1.} [%t] %m}{bold,green}%n</pattern>
</PatternLayout>]]></pre>
- </subsection>
+
+ <h4>Pattern Selectors</h4>
+ <p>
+ The PatternLayout can be configured with a PatternSelector to allow it to choose a pattern to use based on
+ attributes of the log event or other factors. A PatternSelector will normally be configured with a defaultPattern
+ attribute, which is used when other criteria don't match, and a set of PatternMatch elements that identify
+ the various patterns that can be selected.
+ </p>
+ <h5>MarkerPatternSelector</h5>
+ <p>
+ The MarkerPatternSelector selects patterns based on the Marker included in the log event. If the Marker in
+ the log event is equal to or is an ancestor of the name specified on the PatternMatch key attribute, then the
+ pattern specified on that PatternMatch element will be used.
+ </p>
+ <pre class="prettyprint linenums"><![CDATA[<PatternLayout>
+ <MarkerPatternSelector defaultPattern="[%-5level] %c{1.} %msg%n">
+ <PatternMatch key="FLOW" pattern="[%-5level] %c{1.} ====== %C{1.}.%M:%L %msg ======%n"/>
+ </MarkerPatternSelector>
+</PatternLayout>]]></pre>
+ <h5>ScriptPatternSelector</h5>
+ <p>
+ The ScriptPatternSelector executes a script as descibed in the <a href="../configuration.html#Scripts">Scripts</a> section of the
+ Configuration chapter. The script is passed all the properties configured in the Properties section of the
+ configuration, the StrSubstitutor used by the Confguration in the "substitutor" vairables, and the
+ log event in the "logEvent" variable, and is expected to return the value of the PatternMatch key that
+ should be used, or null if the default pattern should be used.
+ </p>
+ <pre class="prettyprint linenums"><![CDATA[<PatternLayout>
+ <ScriptPatternSelector defaultPattern="[%-5level] %c{1.} %C{1.}.%M.%L %msg%n">
+ <Script name="BeanShellSelector" language="bsh"><![CDATA[
+ if (logEvent.getLoggerName().equals("NoLocation")) {
+ return "NoLocation";
+ } else if (logEvent.getMarker() != null && logEvent.getMarker().isInstanceOf("FLOW")) {
+ return "Flow";
+ } else {
+ return null;
+ }]]]]><![CDATA[>
+ </Script>
+ <PatternMatch key="NoLocation" pattern="[%-5level] %c{1.} %msg%n"/>
+ <PatternMatch key="Flow" pattern="[%-5level] %c{1.} ====== %C{1.}.%M:%L %msg ======%n"/>
+ </ScriptPatternSelector>
+</PatternLayout>]]></pre>
+ </subsection>
<a name="RFC5424Layout"/>
<subsection name="RFC5424Layout">
<p>As the name implies, the RFC5424Layout formats LogEvents in accordance with
[05/27] logging-log4j2 git commit: javadoc
Posted by rg...@apache.org.
javadoc
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/80a45f07
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/80a45f07
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/80a45f07
Branch: refs/heads/LOG4J2-1136
Commit: 80a45f07b46928c73d9dc175667e08f699a77aef
Parents: e4ad985
Author: rpopma <rp...@apache.org>
Authored: Sun Oct 4 19:19:34 2015 +0200
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Sun Oct 11 12:40:42 2015 -0700
----------------------------------------------------------------------
.../core/util/datetime/FixedDateFormat.java | 37 ++++++++++++++++++++
1 file changed, 37 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/80a45f07/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/FixedDateFormat.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/FixedDateFormat.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/FixedDateFormat.java
index e8612b3..60bc75fb 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/FixedDateFormat.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/FixedDateFormat.java
@@ -98,10 +98,20 @@ public class FixedDateFormat {
this.escapeCount = escapeCount;
}
+ /**
+ * Returns the full pattern.
+ *
+ * @return the full pattern
+ */
public String getPattern() {
return pattern;
}
+ /**
+ * Returns the date part of the pattern.
+ *
+ * @return the date part of the pattern
+ */
public String getDatePattern() {
return datePattern;
}
@@ -121,14 +131,30 @@ public class FixedDateFormat {
return null;
}
+ /**
+ * Returns the length of the resulting formatted date and time strings.
+ *
+ * @return the length of the resulting formatted date and time strings
+ */
public int getLength() {
return pattern.length() - escapeCount;
}
+ /**
+ * Returns the length of the date part of the resulting formatted string.
+ *
+ * @return the length of the date part of the resulting formatted string
+ */
public int getDatePatternLength() {
return getDatePattern() == null ? 0 : getDatePattern().length() - escapeCount;
}
+ /**
+ * Returns the {@code FastDateFormat} object for formatting the date part of the pattern or {@code null} if the
+ * pattern does not have a date part.
+ *
+ * @return the {@code FastDateFormat} object for formatting the date part of the pattern or {@code null}
+ */
public FastDateFormat getFastDateFormat() {
return getDatePattern() == null ? null : FastDateFormat.getInstance(getDatePattern());
}
@@ -182,10 +208,21 @@ public class FixedDateFormat {
return type == null ? null : new FixedDateFormat(type);
}
+ /**
+ * Returns a new {@code FixedDateFormat} object for the specified {@code FixedFormat} and a {@code null} TimeZone.
+ *
+ * @param format the format to use
+ * @return a new {@code FixedDateFormat} object
+ */
public static FixedDateFormat create(FixedFormat format) {
return new FixedDateFormat(format);
}
+ /**
+ * Returns the full pattern of the selected fixed format.
+ *
+ * @return the full date-time pattern
+ */
public String getFormat() {
return fixedFormat.getPattern();
}
[23/27] logging-log4j2 git commit: [maven-release-plugin] prepare
release log4j-2.4.1
Posted by rg...@apache.org.
[maven-release-plugin] prepare release log4j-2.4.1
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/b81e5c9b
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/b81e5c9b
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/b81e5c9b
Branch: refs/heads/LOG4J2-1136
Commit: b81e5c9bc47a17950485a64d09aa92167c5cbbdb
Parents: 177aefe
Author: rgoers <ra...@dslextreme.com>
Authored: Thu Oct 8 17:49:19 2015 -0700
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Sun Oct 11 12:40:44 2015 -0700
----------------------------------------------------------------------
log4j-1.2-api/pom.xml | 2 +-
log4j-api/pom.xml | 2 +-
log4j-bom/pom.xml | 4 ++--
log4j-core/pom.xml | 2 +-
log4j-distribution/pom.xml | 2 +-
log4j-flume-ng/pom.xml | 2 +-
log4j-iostreams/pom.xml | 2 +-
log4j-jcl/pom.xml | 2 +-
log4j-jmx-gui/pom.xml | 2 +-
log4j-jul/pom.xml | 2 +-
log4j-liquibase/pom.xml | 2 +-
log4j-nosql/pom.xml | 2 +-
log4j-perf/pom.xml | 2 +-
log4j-samples/configuration/pom.xml | 2 +-
log4j-samples/flume-common/pom.xml | 2 +-
log4j-samples/flume-embedded/pom.xml | 2 +-
log4j-samples/flume-remote/pom.xml | 2 +-
log4j-samples/loggerProperties/pom.xml | 2 +-
log4j-samples/pom.xml | 2 +-
log4j-slf4j-impl/pom.xml | 2 +-
log4j-taglib/pom.xml | 2 +-
log4j-to-slf4j/pom.xml | 2 +-
log4j-web/pom.xml | 2 +-
pom.xml | 4 ++--
24 files changed, 26 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b81e5c9b/log4j-1.2-api/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-1.2-api/pom.xml b/log4j-1.2-api/pom.xml
index 1d46ee4..66af18a 100644
--- a/log4j-1.2-api/pom.xml
+++ b/log4j-1.2-api/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId>
- <version>2.4.1-SNAPSHOT</version>
+ <version>2.4.1</version>
<relativePath>../</relativePath>
</parent>
<artifactId>log4j-1.2-api</artifactId>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b81e5c9b/log4j-api/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-api/pom.xml b/log4j-api/pom.xml
index 5f5f6ba..767a07c 100644
--- a/log4j-api/pom.xml
+++ b/log4j-api/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId>
- <version>2.4.1-SNAPSHOT</version>
+ <version>2.4.1</version>
<relativePath>../</relativePath>
</parent>
<artifactId>log4j-api</artifactId>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b81e5c9b/log4j-bom/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-bom/pom.xml b/log4j-bom/pom.xml
index a8d834b..5a800f4 100644
--- a/log4j-bom/pom.xml
+++ b/log4j-bom/pom.xml
@@ -26,7 +26,7 @@
<description>Apache Log4j Bill of Materials</description>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-bom</artifactId>
- <version>2.4.1-SNAPSHOT</version>
+ <version>2.4.1</version>
<packaging>pom</packaging>
<dependencyManagement>
<dependencies>
@@ -125,6 +125,6 @@
</build>
<scm>
- <tag>log4j-2.3</tag>
+ <tag>log4j-2.4.1</tag>
</scm>
</project>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b81e5c9b/log4j-core/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-core/pom.xml b/log4j-core/pom.xml
index 6ef0f7b..d510a69 100644
--- a/log4j-core/pom.xml
+++ b/log4j-core/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId>
- <version>2.4.1-SNAPSHOT</version>
+ <version>2.4.1</version>
<relativePath>../</relativePath>
</parent>
<artifactId>log4j-core</artifactId>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b81e5c9b/log4j-distribution/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-distribution/pom.xml b/log4j-distribution/pom.xml
index 6ea5423..85b7eed 100644
--- a/log4j-distribution/pom.xml
+++ b/log4j-distribution/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId>
- <version>2.4.1-SNAPSHOT</version>
+ <version>2.4.1</version>
<relativePath>../</relativePath>
</parent>
<artifactId>log4j-distribution</artifactId>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b81e5c9b/log4j-flume-ng/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-flume-ng/pom.xml b/log4j-flume-ng/pom.xml
index ca83e38..c2805d3 100644
--- a/log4j-flume-ng/pom.xml
+++ b/log4j-flume-ng/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId>
- <version>2.4.1-SNAPSHOT</version>
+ <version>2.4.1</version>
<relativePath>../</relativePath>
</parent>
<artifactId>log4j-flume-ng</artifactId>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b81e5c9b/log4j-iostreams/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-iostreams/pom.xml b/log4j-iostreams/pom.xml
index c7aa19d..190b379 100644
--- a/log4j-iostreams/pom.xml
+++ b/log4j-iostreams/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId>
- <version>2.4.1-SNAPSHOT</version>
+ <version>2.4.1</version>
<relativePath>../</relativePath>
</parent>
<artifactId>log4j-iostreams</artifactId>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b81e5c9b/log4j-jcl/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-jcl/pom.xml b/log4j-jcl/pom.xml
index 43a4e63..1b297e1 100644
--- a/log4j-jcl/pom.xml
+++ b/log4j-jcl/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId>
- <version>2.4.1-SNAPSHOT</version>
+ <version>2.4.1</version>
<relativePath>../</relativePath>
</parent>
<artifactId>log4j-jcl</artifactId>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b81e5c9b/log4j-jmx-gui/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-jmx-gui/pom.xml b/log4j-jmx-gui/pom.xml
index d517cfc..2b91b82 100644
--- a/log4j-jmx-gui/pom.xml
+++ b/log4j-jmx-gui/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId>
- <version>2.4.1-SNAPSHOT</version>
+ <version>2.4.1</version>
<relativePath>../</relativePath>
</parent>
<artifactId>log4j-jmx-gui</artifactId>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b81e5c9b/log4j-jul/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-jul/pom.xml b/log4j-jul/pom.xml
index b10cfcb..99b8cbd 100644
--- a/log4j-jul/pom.xml
+++ b/log4j-jul/pom.xml
@@ -20,7 +20,7 @@
<parent>
<artifactId>log4j</artifactId>
<groupId>org.apache.logging.log4j</groupId>
- <version>2.4.1-SNAPSHOT</version>
+ <version>2.4.1</version>
<relativePath>../</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b81e5c9b/log4j-liquibase/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-liquibase/pom.xml b/log4j-liquibase/pom.xml
index 2e69961..e10d76b 100644
--- a/log4j-liquibase/pom.xml
+++ b/log4j-liquibase/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId>
- <version>2.4.1-SNAPSHOT</version>
+ <version>2.4.1</version>
<relativePath>../</relativePath>
</parent>
<artifactId>log4j-liquibase</artifactId>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b81e5c9b/log4j-nosql/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-nosql/pom.xml b/log4j-nosql/pom.xml
index b8ded12..be86211 100644
--- a/log4j-nosql/pom.xml
+++ b/log4j-nosql/pom.xml
@@ -20,7 +20,7 @@
<parent>
<artifactId>log4j</artifactId>
<groupId>org.apache.logging.log4j</groupId>
- <version>2.4.1-SNAPSHOT</version>
+ <version>2.4.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b81e5c9b/log4j-perf/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-perf/pom.xml b/log4j-perf/pom.xml
index d1de024..e2fa341 100644
--- a/log4j-perf/pom.xml
+++ b/log4j-perf/pom.xml
@@ -20,7 +20,7 @@
<parent>
<artifactId>log4j</artifactId>
<groupId>org.apache.logging.log4j</groupId>
- <version>2.4.1-SNAPSHOT</version>
+ <version>2.4.1</version>
<relativePath>../</relativePath>
</parent>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b81e5c9b/log4j-samples/configuration/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-samples/configuration/pom.xml b/log4j-samples/configuration/pom.xml
index 61586ff..7a0f25a 100644
--- a/log4j-samples/configuration/pom.xml
+++ b/log4j-samples/configuration/pom.xml
@@ -20,7 +20,7 @@
<parent>
<artifactId>log4j-samples</artifactId>
<groupId>org.apache.logging.log4j.samples</groupId>
- <version>2.4.1-SNAPSHOT</version>
+ <version>2.4.1</version>
</parent>
<artifactId>log4j-samples-configuration</artifactId>
<packaging>jar</packaging>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b81e5c9b/log4j-samples/flume-common/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-samples/flume-common/pom.xml b/log4j-samples/flume-common/pom.xml
index 587d180..af5ff3d 100644
--- a/log4j-samples/flume-common/pom.xml
+++ b/log4j-samples/flume-common/pom.xml
@@ -20,7 +20,7 @@
<parent>
<artifactId>log4j-samples</artifactId>
<groupId>org.apache.logging.log4j.samples</groupId>
- <version>2.4.1-SNAPSHOT</version>
+ <version>2.4.1</version>
</parent>
<artifactId>log4j-samples-flume-common</artifactId>
<packaging>jar</packaging>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b81e5c9b/log4j-samples/flume-embedded/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-samples/flume-embedded/pom.xml b/log4j-samples/flume-embedded/pom.xml
index 83b230d..e848d9c 100644
--- a/log4j-samples/flume-embedded/pom.xml
+++ b/log4j-samples/flume-embedded/pom.xml
@@ -20,7 +20,7 @@
<parent>
<artifactId>log4j-samples</artifactId>
<groupId>org.apache.logging.log4j.samples</groupId>
- <version>2.4.1-SNAPSHOT</version>
+ <version>2.4.1</version>
</parent>
<artifactId>log4j-samples-flume-embedded</artifactId>
<packaging>war</packaging>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b81e5c9b/log4j-samples/flume-remote/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-samples/flume-remote/pom.xml b/log4j-samples/flume-remote/pom.xml
index 2fcc5c5..6876e90 100644
--- a/log4j-samples/flume-remote/pom.xml
+++ b/log4j-samples/flume-remote/pom.xml
@@ -20,7 +20,7 @@
<parent>
<artifactId>log4j-samples</artifactId>
<groupId>org.apache.logging.log4j.samples</groupId>
- <version>2.4.1-SNAPSHOT</version>
+ <version>2.4.1</version>
</parent>
<artifactId>log4j-samples-flume-remote</artifactId>
<packaging>war</packaging>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b81e5c9b/log4j-samples/loggerProperties/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-samples/loggerProperties/pom.xml b/log4j-samples/loggerProperties/pom.xml
index 527214b..6e28887 100644
--- a/log4j-samples/loggerProperties/pom.xml
+++ b/log4j-samples/loggerProperties/pom.xml
@@ -20,7 +20,7 @@
<parent>
<artifactId>log4j-samples</artifactId>
<groupId>org.apache.logging.log4j.samples</groupId>
- <version>2.4.1-SNAPSHOT</version>
+ <version>2.4.1</version>
</parent>
<artifactId>log4j-samples-loggerProperties</artifactId>
<packaging>jar</packaging>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b81e5c9b/log4j-samples/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-samples/pom.xml b/log4j-samples/pom.xml
index ea9867e..178fd67 100644
--- a/log4j-samples/pom.xml
+++ b/log4j-samples/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId>
- <version>2.4.1-SNAPSHOT</version>
+ <version>2.4.1</version>
<relativePath>../</relativePath>
</parent>
<groupId>org.apache.logging.log4j.samples</groupId>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b81e5c9b/log4j-slf4j-impl/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-slf4j-impl/pom.xml b/log4j-slf4j-impl/pom.xml
index cf39df5..12ce869 100644
--- a/log4j-slf4j-impl/pom.xml
+++ b/log4j-slf4j-impl/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId>
- <version>2.4.1-SNAPSHOT</version>
+ <version>2.4.1</version>
<relativePath>../</relativePath>
</parent>
<artifactId>log4j-slf4j-impl</artifactId>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b81e5c9b/log4j-taglib/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-taglib/pom.xml b/log4j-taglib/pom.xml
index c15eb23..e12a16b 100644
--- a/log4j-taglib/pom.xml
+++ b/log4j-taglib/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId>
- <version>2.4.1-SNAPSHOT</version>
+ <version>2.4.1</version>
<relativePath>../</relativePath>
</parent>
<artifactId>log4j-taglib</artifactId>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b81e5c9b/log4j-to-slf4j/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml
index 0bbd3e1..cb43e53 100644
--- a/log4j-to-slf4j/pom.xml
+++ b/log4j-to-slf4j/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId>
- <version>2.4.1-SNAPSHOT</version>
+ <version>2.4.1</version>
<relativePath>../</relativePath>
</parent>
<artifactId>log4j-to-slf4j</artifactId>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b81e5c9b/log4j-web/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-web/pom.xml b/log4j-web/pom.xml
index 472ac18..3c885b8 100644
--- a/log4j-web/pom.xml
+++ b/log4j-web/pom.xml
@@ -20,7 +20,7 @@
<parent>
<artifactId>log4j</artifactId>
<groupId>org.apache.logging.log4j</groupId>
- <version>2.4.1-SNAPSHOT</version>
+ <version>2.4.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b81e5c9b/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 78dad40..95cd651 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
<artifactId>log4j</artifactId>
<packaging>pom</packaging>
<name>Apache Log4j 2</name>
- <version>2.4.1-SNAPSHOT</version>
+ <version>2.4.1</version>
<parent>
<groupId>org.apache</groupId>
<artifactId>apache</artifactId>
@@ -155,7 +155,7 @@
<connection>scm:git:http://git-wip-us.apache.org/repos/asf/logging-log4j2.git</connection>
<developerConnection>scm:git:https://git-wip-us.apache.org/repos/asf/logging-log4j2.git</developerConnection>
<url>https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;a=summary</url>
- <tag>log4j-2.3</tag>
+ <tag>log4j-2.4.1</tag>
</scm>
<organization>
<name>Apache Software Foundation</name>
[10/27] logging-log4j2 git commit: LOG4J2-935 Performance improvement
converting Strings to byte[] arrays.
Posted by rg...@apache.org.
LOG4J2-935 Performance improvement converting Strings to byte[] arrays.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/6630dd75
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/6630dd75
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/6630dd75
Branch: refs/heads/LOG4J2-1136
Commit: 6630dd75c70ca74245e226466306b4f7cc63dba5
Parents: 8b070ed
Author: rpopma <rp...@apache.org>
Authored: Mon Oct 5 01:44:05 2015 +0200
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Sun Oct 11 12:40:43 2015 -0700
----------------------------------------------------------------------
.../log4j/core/layout/AbstractStringLayout.java | 18 +++++++++++++++---
src/changes/changes.xml | 3 +++
2 files changed, 18 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/6630dd75/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
index cd10881..3a5d39b 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
@@ -16,6 +16,7 @@
*/
package org.apache.logging.log4j.core.layout;
+import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
@@ -40,6 +41,7 @@ public abstract class AbstractStringLayout extends AbstractLayout<String> {
*/
// TODO: Charset is not serializable. Implement read/writeObject() ?
private final Charset charset;
+ private final String charsetName;
protected AbstractStringLayout(final Charset charset) {
this(charset, null, null);
@@ -48,6 +50,7 @@ public abstract class AbstractStringLayout extends AbstractLayout<String> {
protected AbstractStringLayout(final Charset charset, final byte[] header, final byte[] footer) {
super(header, footer);
this.charset = charset == null ? StandardCharsets.UTF_8 : charset;
+ this.charsetName = this.charset.name();
}
/**
@@ -59,7 +62,12 @@ public abstract class AbstractStringLayout extends AbstractLayout<String> {
*/
static byte[] toBytes(final String str, final Charset charset) {
if (str != null) {
- return str.getBytes(charset != null ? charset : Charset.defaultCharset());
+ final Charset actual = charset != null ? charset : Charset.defaultCharset();
+ try {
+ return str.getBytes(actual.name());
+ } catch (UnsupportedEncodingException e) {
+ return str.getBytes(actual);
+ }
}
return null;
}
@@ -80,7 +88,11 @@ public abstract class AbstractStringLayout extends AbstractLayout<String> {
}
protected byte[] getBytes(final String s) {
- return s.getBytes(charset);
+ try {
+ return s.getBytes(charsetName);
+ } catch (UnsupportedEncodingException e) {
+ return s.getBytes(charset);
+ }
}
protected Charset getCharset() {
@@ -103,7 +115,7 @@ public abstract class AbstractStringLayout extends AbstractLayout<String> {
*/
@Override
public byte[] toByteArray(final LogEvent event) {
- return toSerializable(event).getBytes(charset);
+ return getBytes(toSerializable(event));
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/6630dd75/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 65f3a12..1ab8b9f 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -66,6 +66,9 @@
<action issue="LOG4J2-1126" dev="ggregory" type="fix">
Web site corrections and updates.
</action>
+ <action issue="LOG4J2-935" dev="rpopma" type="update">
+ Performance improvement when converting Strings to byte[] arrays.
+ </action>
<action issue="LOG4J2-1040" dev="ggregory" type="update">
Update MongoDB driver from 2.13.3 to 3.0.4.
</action>
[09/27] logging-log4j2 git commit: LOG4J2-1151 benchmark updates
Posted by rg...@apache.org.
LOG4J2-1151 benchmark updates
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/f3dee40b
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/f3dee40b
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/f3dee40b
Branch: refs/heads/LOG4J2-1136
Commit: f3dee40b7c1c77f36b6ce0e7988c130a220857d7
Parents: ec8fd28
Author: rpopma <rp...@apache.org>
Authored: Mon Oct 5 15:10:48 2015 +0200
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Sun Oct 11 12:40:43 2015 -0700
----------------------------------------------------------------------
.../log4j/perf/jmh/StringEncodingBenchmark.java | 119 ++++++++++++++-----
1 file changed, 86 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f3dee40b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/StringEncodingBenchmark.java
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/StringEncodingBenchmark.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/StringEncodingBenchmark.java
index 26f987c..4159b2a 100644
--- a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/StringEncodingBenchmark.java
+++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/StringEncodingBenchmark.java
@@ -17,7 +17,11 @@
package org.apache.logging.log4j.perf.jmh;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.CharacterCodingException;
import java.nio.charset.Charset;
+import java.nio.charset.CharsetEncoder;
import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.Benchmark;
@@ -31,70 +35,119 @@ import org.openjdk.jmh.annotations.State;
* Tests Log4j2 StringEncoding performance.
*/
// ============================== HOW TO RUN THIS TEST: ====================================
+//(Quick build: mvn -DskipTests=true clean package -pl log4j-perf -am )
//
-// single thread:
-// java -jar log4j-perf/target/benchmarks.jar ".*StringEncoding.*" -f 1 -wi 5 -i 5
+// java -jar log4j-perf/target/benchmarks.jar ".*StringEncoding.*" -f 1 -wi 5 -i 10
+//
+// Latency numbers instead of throughput:
+// java -jar log4j-perf/target/benchmarks.jar ".*StringEncoding.*" -f 1 -wi 5 -i 10 -tu ns -bm sample
//
// Usage help:
// java -jar log4j-perf/target/benchmarks.jar -help
//
@State(Scope.Thread)
public class StringEncodingBenchmark {
-
- private final static String STR = "AB!(%087936DZYXQWEIOP$#^~-=/><nb"; // length=32
+
+ private final static String LOGMSG = "2015-10-02 00:26:28,517 DEBUG (main) [o.a.l.l.p.j.StringEncodingBenchmark] - Very short log message."; // length=100
private static final String STRING_ISO8859_1 = "ISO-8859-1";
+ private static final String STRING_US_ASCII = "US-ASCII";
+ private static final String STRING_SHIFT_JIS = "SHIFT_JIS";
private static final Charset CHARSET_ISO8859_1 = Charset.forName(STRING_ISO8859_1);
private static final Charset CHARSET_DEFAULT = Charset.defaultCharset();
private static final String DEFAULT_ENCODING = CHARSET_DEFAULT.name();
- private static final String STRING_SHIFT_JIS = "SHIFT_JIS";
private static final Charset CHARSET_SHIFT_JIS = Charset.forName(STRING_SHIFT_JIS);
+ private static final Charset CHARSET_US_ASCII = Charset.forName(STRING_US_ASCII);
+ private static final CharsetEncoder ENCODER_SHIFT_JIS = CHARSET_SHIFT_JIS.newEncoder();
+ private static final CharsetEncoder ENCODER_ISO8859_1 = CHARSET_ISO8859_1.newEncoder();
+
+ @Benchmark
+ @BenchmarkMode(Mode.SampleTime)
+ @OutputTimeUnit(TimeUnit.NANOSECONDS)
+ public byte[] stringGetBytes() {
+ return LOGMSG.getBytes();
+ }
+
+ @Benchmark
+ @BenchmarkMode(Mode.SampleTime)
+ @OutputTimeUnit(TimeUnit.NANOSECONDS)
+ public byte[] stringGetBytesString88591() throws Exception {
+ return LOGMSG.getBytes(STRING_ISO8859_1);
+ }
+
+ @Benchmark
+ @BenchmarkMode(Mode.SampleTime)
+ @OutputTimeUnit(TimeUnit.NANOSECONDS)
+ public byte[] stringGetBytesCharSet88591() {
+ return LOGMSG.getBytes(CHARSET_ISO8859_1);
+ }
+
+ @Benchmark
+ @BenchmarkMode(Mode.SampleTime)
+ @OutputTimeUnit(TimeUnit.NANOSECONDS)
+ public byte[] stringGetBytesStringUsAscii() throws Exception {
+ return LOGMSG.getBytes(STRING_US_ASCII);
+ }
+
+ @Benchmark
+ @BenchmarkMode(Mode.SampleTime)
+ @OutputTimeUnit(TimeUnit.NANOSECONDS)
+ public byte[] stringGetBytesCharSetUsAscii() {
+ return LOGMSG.getBytes(CHARSET_US_ASCII);
+ }
@Benchmark
- @BenchmarkMode(Mode.Throughput)
- @OutputTimeUnit(TimeUnit.SECONDS)
- public byte[] throughputStringGetBytes() {
- return STR.getBytes();
+ @BenchmarkMode(Mode.SampleTime)
+ @OutputTimeUnit(TimeUnit.NANOSECONDS)
+ public byte[] stringGetBytesStringDefault() throws Exception {
+ return LOGMSG.getBytes(DEFAULT_ENCODING);
}
@Benchmark
- @BenchmarkMode(Mode.Throughput)
- @OutputTimeUnit(TimeUnit.SECONDS)
- public byte[] throughputStringGetBytesString88591() throws Exception {
- return STR.getBytes(STRING_ISO8859_1);
+ @BenchmarkMode(Mode.SampleTime)
+ @OutputTimeUnit(TimeUnit.NANOSECONDS)
+ public byte[] stringGetBytesCharSetDefault() {
+ return LOGMSG.getBytes(CHARSET_DEFAULT);
}
@Benchmark
- @BenchmarkMode(Mode.Throughput)
- @OutputTimeUnit(TimeUnit.SECONDS)
- public byte[] throughputStringGetBytesCharSet88591() {
- return STR.getBytes(CHARSET_ISO8859_1);
+ @BenchmarkMode(Mode.SampleTime)
+ @OutputTimeUnit(TimeUnit.NANOSECONDS)
+ public byte[] stringGetBytesStringShiftJIS() throws Exception {
+ return LOGMSG.getBytes(STRING_SHIFT_JIS);
}
@Benchmark
- @BenchmarkMode(Mode.Throughput)
- @OutputTimeUnit(TimeUnit.SECONDS)
- public byte[] throughputStringGetBytesStringDefault() throws Exception {
- return STR.getBytes(DEFAULT_ENCODING);
+ @BenchmarkMode(Mode.SampleTime)
+ @OutputTimeUnit(TimeUnit.NANOSECONDS)
+ public byte[] stringGetBytesCharSetShiftJIS() {
+ return LOGMSG.getBytes(CHARSET_SHIFT_JIS);
}
@Benchmark
- @BenchmarkMode(Mode.Throughput)
- @OutputTimeUnit(TimeUnit.SECONDS)
- public byte[] throughputStringGetBytesCharSetDefault() {
- return STR.getBytes(CHARSET_DEFAULT);
+ @BenchmarkMode(Mode.SampleTime)
+ @OutputTimeUnit(TimeUnit.NANOSECONDS)
+ public byte[] encoderShiftJIS() throws CharacterCodingException {
+ ByteBuffer buf = ENCODER_SHIFT_JIS.encode(CharBuffer.wrap(LOGMSG));
+ return buf.array();
}
@Benchmark
- @BenchmarkMode(Mode.Throughput)
- @OutputTimeUnit(TimeUnit.SECONDS)
- public byte[] throughputStringGetBytesStringShiftJIS() throws Exception {
- return STR.getBytes(STRING_SHIFT_JIS);
+ @BenchmarkMode(Mode.SampleTime)
+ @OutputTimeUnit(TimeUnit.NANOSECONDS)
+ public byte[] encoderIso8859_1() throws CharacterCodingException {
+ ByteBuffer buf = ENCODER_ISO8859_1.encode(CharBuffer.wrap(LOGMSG));
+ return buf.array();
}
@Benchmark
- @BenchmarkMode(Mode.Throughput)
- @OutputTimeUnit(TimeUnit.SECONDS)
- public byte[] throughputStringGetBytesCharSetShiftJIS() {
- return STR.getBytes(CHARSET_SHIFT_JIS);
+ @BenchmarkMode(Mode.SampleTime)
+ @OutputTimeUnit(TimeUnit.NANOSECONDS)
+ public byte[] customIso8859_1() throws CharacterCodingException {
+ final int length = LOGMSG.length();
+ final byte[] result = new byte[length];
+ for (int i = 0; i < length; i++) {
+ result[i] = (byte) LOGMSG.charAt(i);
+ }
+ return result;
}
}
[04/27] logging-log4j2 git commit: LOG4J2-1149 Fixed bug where
PatternLayout predefined date pattern with time zone always renders default
date format.
Posted by rg...@apache.org.
LOG4J2-1149 Fixed bug where PatternLayout predefined date pattern with
time zone always renders default date format.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/558dbbb5
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/558dbbb5
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/558dbbb5
Branch: refs/heads/LOG4J2-1136
Commit: 558dbbb512f5fa853c6c850581ac2992e6115420
Parents: 80a45f0
Author: rpopma <rp...@apache.org>
Authored: Sun Oct 4 23:28:37 2015 +0200
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Sun Oct 11 12:40:42 2015 -0700
----------------------------------------------------------------------
.../core/pattern/DatePatternConverter.java | 9 +++--
.../core/pattern/DatePatternConverterTest.java | 41 +++++++++++++++++---
src/changes/changes.xml | 3 ++
3 files changed, 45 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/558dbbb5/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/DatePatternConverter.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/DatePatternConverter.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/DatePatternConverter.java
index ce7b8ef..230cfe4 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/DatePatternConverter.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/DatePatternConverter.java
@@ -165,18 +165,21 @@ public final class DatePatternConverter extends LogEventPatternConverter impleme
if (UNIX_MILLIS_FORMAT.equals(patternOption)) {
return new UnixMillisFormatter();
}
+ // LOG4J2-1149: patternOption may be a name (if a time zone was specified)
+ final FixedDateFormat.FixedFormat fixedFormat = FixedDateFormat.FixedFormat.lookup(patternOption);
+ final String pattern = fixedFormat == null ? patternOption : fixedFormat.getPattern();
// if the option list contains a TZ option, then set it.
TimeZone tz = null;
- if (options.length > 1) {
+ if (options.length > 1 && options[1] != null) {
tz = TimeZone.getTimeZone(options[1]);
}
try {
- final FastDateFormat tempFormat = FastDateFormat.getInstance(patternOption, tz);
+ final FastDateFormat tempFormat = FastDateFormat.getInstance(pattern, tz);
return new PatternFormatter(tempFormat);
} catch (final IllegalArgumentException e) {
- LOGGER.warn("Could not instantiate FastDateFormat with pattern " + patternOption, e);
+ LOGGER.warn("Could not instantiate FastDateFormat with pattern " + pattern, e);
// default to the DEFAULT format
return createFormatter(FixedDateFormat.create(FixedFormat.DEFAULT));
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/558dbbb5/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/DatePatternConverterTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/DatePatternConverterTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/DatePatternConverterTest.java
index 2981a68..cd06e8b 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/DatePatternConverterTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/DatePatternConverterTest.java
@@ -38,7 +38,7 @@ public class DatePatternConverterTest {
*/
private static final String ISO8601_FORMAT = FixedDateFormat.FixedFormat.ISO8601.name();
- private static final String[] ISO8601_FORMAT_OPTIONS = { ISO8601_FORMAT };
+ private static final String[] ISO8601_FORMAT_OPTIONS = {ISO8601_FORMAT};
@Test
public void testNewInstanceAllowsNullParameter() {
@@ -67,6 +67,37 @@ public class DatePatternConverterTest {
assertEquals(expected, sb.toString());
}
+ @Test
+ public void testFormatLogEventStringBuilderIso8601Timezone() {
+ final LogEvent event = new MyLogEvent();
+ final String[] optionsWithTimezone = {ISO8601_FORMAT, "JST"};
+ final DatePatternConverter converter = DatePatternConverter.newInstance(optionsWithTimezone);
+ final StringBuilder sb = new StringBuilder();
+ converter.format(event, sb);
+
+ // JST=Japan Standard Time: UTC+9:00, but December has day light savings, so +8 hours
+ final String expected = "2011-12-30T18:56:35,987";
+ assertEquals(expected, sb.toString());
+ }
+
+ @Test
+ public void testPredefinedFormatWithTimezone() {
+ for (final FixedDateFormat.FixedFormat format : FixedDateFormat.FixedFormat.values()) {
+ final String[] options = {format.name(), "PDT"}; // Pacific Daylight Time=UTC-8:00
+ final DatePatternConverter converter = DatePatternConverter.newInstance(options);
+ assertEquals(format.getPattern(), converter.getPattern());
+ }
+ }
+
+ @Test
+ public void testPredefinedFormatWithoutTimezone() {
+ for (final FixedDateFormat.FixedFormat format : FixedDateFormat.FixedFormat.values()) {
+ final String[] options = {format.name()};
+ final DatePatternConverter converter = DatePatternConverter.newInstance(options);
+ assertEquals(format.getPattern(), converter.getPattern());
+ }
+ }
+
private class MyLogEvent extends AbstractLogEvent {
private static final long serialVersionUID = 0;
@@ -111,7 +142,7 @@ public class DatePatternConverterTest {
@Test
public void testFormatDateStringBuilderOriginalPattern() {
- final String[] pattern = { "yyyy/MM/dd HH-mm-ss.SSS" };
+ final String[] pattern = {"yyyy/MM/dd HH-mm-ss.SSS"};
final DatePatternConverter converter = DatePatternConverter.newInstance(pattern);
final StringBuilder sb = new StringBuilder();
converter.format(date(2001, 1, 1), sb);
@@ -169,19 +200,19 @@ public class DatePatternConverterTest {
@Test
public void testGetPatternReturnsDefaultForInvalidPattern() {
- final String[] invalid = { "ABC I am not a valid date pattern" };
+ final String[] invalid = {"ABC I am not a valid date pattern"};
assertEquals(DEFAULT_PATTERN, DatePatternConverter.newInstance(invalid).getPattern());
}
@Test
public void testGetPatternReturnsNullForUnix() {
- final String[] options = { "UNIX" };
+ final String[] options = {"UNIX"};
assertNull(DatePatternConverter.newInstance(options).getPattern());
}
@Test
public void testGetPatternReturnsNullForUnixMillis() {
- final String[] options = { "UNIX_MILLIS" };
+ final String[] options = {"UNIX_MILLIS"};
assertNull(DatePatternConverter.newInstance(options).getPattern());
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/558dbbb5/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 7b9c7a7..7d18eaf 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -39,6 +39,9 @@
<action issue="LOG4J2-1020" dev="mikes" type="add">
Add possibility to set shutdown timeout on AsyncAppender.
</action>
+ <action issue="LOG4J2-1149" dev="rpopma" type="fix">
+ Fixed bug where PatternLayout predefined date pattern with time zone always renders default date format.
+ </action>
<action issue="LOG4J2-1050" dev="rpopma" type="fix">
Fixed Log4jLookup.
</action>
[02/27] logging-log4j2 git commit: LOG4J2-1149 fix JUnit test to give
correct results if daylight savings is applied
Posted by rg...@apache.org.
LOG4J2-1149 fix JUnit test to give correct results if daylight savings
is applied
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/8b070ede
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/8b070ede
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/8b070ede
Branch: refs/heads/LOG4J2-1136
Commit: 8b070ede5c4b135bc25a9bba02993216b2ac1544
Parents: ab17f70
Author: rpopma <rp...@apache.org>
Authored: Mon Oct 5 00:58:54 2015 +0200
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Sun Oct 11 12:40:42 2015 -0700
----------------------------------------------------------------------
.../core/pattern/DatePatternConverterTest.java | 28 ++++++++++++++++----
1 file changed, 23 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8b070ede/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/DatePatternConverterTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/DatePatternConverterTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/DatePatternConverterTest.java
index cd06e8b..1bd70a9 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/DatePatternConverterTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/DatePatternConverterTest.java
@@ -16,8 +16,10 @@
*/
package org.apache.logging.log4j.core.pattern;
+import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
+import java.util.TimeZone;
import org.apache.logging.log4j.core.AbstractLogEvent;
import org.apache.logging.log4j.core.LogEvent;
@@ -68,18 +70,34 @@ public class DatePatternConverterTest {
}
@Test
- public void testFormatLogEventStringBuilderIso8601Timezone() {
+ public void testFormatLogEventStringBuilderIso8601TimezoneUTC() {
+ final LogEvent event = new MyLogEvent();
+ final DatePatternConverter converter = DatePatternConverter.newInstance(new String[] {"ISO8601", "UTC"});
+ final StringBuilder sb = new StringBuilder();
+ converter.format(event, sb);
+
+ final String expected = "2011-12-30T09:56:35,987";
+ assertEquals(expected, sb.toString());
+ }
+
+ @Test
+ public void testFormatLogEventStringBuilderIso8601TimezoneJST() {
final LogEvent event = new MyLogEvent();
final String[] optionsWithTimezone = {ISO8601_FORMAT, "JST"};
final DatePatternConverter converter = DatePatternConverter.newInstance(optionsWithTimezone);
final StringBuilder sb = new StringBuilder();
converter.format(event, sb);
- // JST=Japan Standard Time: UTC+9:00, but December has day light savings, so +8 hours
- final String expected = "2011-12-30T18:56:35,987";
+ // JST=Japan Standard Time: UTC+9:00
+ final TimeZone tz = TimeZone.getTimeZone("JST");
+ final SimpleDateFormat sdf = new SimpleDateFormat(converter.getPattern());
+ sdf.setTimeZone(tz);
+ final long adjusted = event.getTimeMillis() + tz.getDSTSavings();
+ final String expected = sdf.format(new Date(adjusted));
+ // final String expected = "2011-12-30T18:56:35,987"; // in CET (Central Eastern Time: Amsterdam)
assertEquals(expected, sb.toString());
}
-
+
@Test
public void testPredefinedFormatWithTimezone() {
for (final FixedDateFormat.FixedFormat format : FixedDateFormat.FixedFormat.values()) {
@@ -88,7 +106,7 @@ public class DatePatternConverterTest {
assertEquals(format.getPattern(), converter.getPattern());
}
}
-
+
@Test
public void testPredefinedFormatWithoutTimezone() {
for (final FixedDateFormat.FixedFormat format : FixedDateFormat.FixedFormat.values()) {
[26/27] logging-log4j2 git commit: Prepare for release
Posted by rg...@apache.org.
Prepare for release
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/177aefef
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/177aefef
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/177aefef
Branch: refs/heads/LOG4J2-1136
Commit: 177aefef6ea0556c3edfb9fa10bf353ff8bea299
Parents: 8acedb4
Author: rgoers <ra...@dslextreme.com>
Authored: Thu Oct 8 17:34:00 2015 -0700
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Sun Oct 11 12:40:44 2015 -0700
----------------------------------------------------------------------
RELEASE-NOTES.txt | 118 ++++++++++-----------------------------
pom.xml | 4 +-
src/changes/announcement.vm | 4 +-
src/changes/changes.xml | 12 ++--
4 files changed, 39 insertions(+), 99 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/177aefef/RELEASE-NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index dbc68cb..2a993f2 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -1,111 +1,51 @@
- Apache Log4j 2.4 RELEASE NOTES
+ Apache Log4j 2.4.1 RELEASE NOTES
-The Apache Log4j 2 team is pleased to announce the Log4j 2.4 release!
+The Apache Log4j 2 team is pleased to announce the Log4j 2.4.1 release!
Apache log4j is a well known framework for logging application behavior. Log4j 2 is an upgrade to
Log4j that provides significant improvements over its predecessor, Log4j 1.x, and provides
many other modern features such as support for Markers, property substitution using Lookups, and asynchronous
Loggers. In addition, Log4j 2 will not lose events while reconfiguring.
-This is the eighth GA release. It contains several bugfixes and new features. As of this release
-Log4j now requires a minimum of Java 7.
+This is the ninth GA release. It contains several bugfixes and new features.
+Log4j 2 requires a minimum of Java 7.
-GA Release 2.4
+GA Release 2.4.1
Changes in this version include:
New features:
-o LOG4J2-635: Add support for configuration via Properties.
-o LOG4J2-952: Add ConfigurationBuilder.
-o LOG4J2-599: Added support for Java 8 lambda expressions to lazily construct a log message only if
- the requested log level is enabled.
-o LOG4J2-1118: Updated Logger wrapper generator tool to add Java 8 lambda support for custom log levels.
-o LOG4J2-1107: New Appender for Apache Kafka. Thanks to Mikael Ståldal.
-o LOG4J2-1113: New publisher Appender for ZeroMQ (using JeroMQ). Thanks to Gary Gregory.
-o LOG4J2-1088: Add Comma Separated Value (CSV) layouts for parameter and event logging. Thanks to Gary Gregory.
-o LOG4J2-1090: Add Core Configurator APIs to change a logger's level.
-o LOG4J2-1105: Add API org.apache.logging.log4j.Level.isInRange(Level, Level). Thanks to Gary Gregory.
-o LOG4J2-1106: Add a LevelRangeFilter class. Thanks to Gary Gregory.
-o LOG4J2-1076: Added support for system nanosecond time in pattern layout.
-o LOG4J2-1075: Added support for compressing to bzip2 format on file rollover.
-o LOG4J2-1077: Support additional Apache Commons Compress compression formats on rollover: Deflate, Pack200, XY.
-o LOG4J2-767: New module for Liquibase integration. Thanks to Mikael Ståldal.
-o LOG4J2-1023: New RewritePolicy for changing level of a log event. Thanks to Mikael Ståldal.
-o LOG4J2-1015: Add a way to route messages based on the %marker in Layout for RoutingAppender. Thanks to Daniel Marcotte.
-o LOG4J2-1050: Add a Log4jLookup class to help write log files relative to log4j2.xml. Thanks to Adam Retter.
-o LOG4J2-1057: Add API org.apache.logging.log4j.LogManager.getFormatterLogger().
-o LOG4J2-1066: Expose Log4jContextFactory's ShutdownCallbackRegistry. Thanks to Charles Allen.
+o LOG4J2-1129: Allow PatternLayout to select a pattern to use based on some selection criteria.
+o LOG4J2-1145: Add %equals to PatternLayout to test and replace patterns with strings.
+o LOG4J2-1147: Add %equalsIgnoreCase to PatternLayout to test and replace patterns with strings.
+o LOG4J2-1146: Add %notEmpty to PatternLayout to avoid output of patterns where all variables are empty.
+o LOG4J2-1020: Add possibility to set shutdown timeout on AsyncAppender.
Fixed Bugs:
-o LOG4J2-1121: Fixed potential race condition on reconfiguration. Introduced ReliabilityStrategy to facilitate
- switching between different mechanisms for preventing log events from being dropped on reconfiguration.
-o LOG4J2-1123: Core Configurator.initialize(String, ClassLoader, String) fails to work when config location is a file path. Thanks to Gary Gregory.
-o LOG4J2-1117: OutputStreamManager in ConsoleAppender leaking managers. Thanks to Marcus Thiesen.
-o LOG4J2-1044: Write pending events to Flume when the appender is stopped.
-o LOG4J2-1108: NullPointerException when passing null to java.util.logging.Logger.setLevel(). Thanks to Mikael Ståldal.
-o LOG4J2-1110: org.apache.logging.log4j.jul.CoreLogger.setLevel() checks for security permission too late.
-o LOG4J2-1084: Misleading StatusLogger WARN event in LogManager with java.util.Map. Thanks to Philipp Schneider.
-o LOG4J2-1051: NoClassDefFoundError when starting app on Google App Engine. Thanks to Lukasz Lenart.
-o LOG4J2-684: ExtendedThrowablePatternConverter does not print suppressed exceptions. Thanks to Joern Huxhorn, Mauro Molinari.
-o LOG4J2-1069: Improper handling of JSON escape chars when deserializing JSON log events. Thanks to Sam Braam.
-o LOG4J2-1068: Exceptions not logged when using TcpSocketServer + SerializedLayout. Thanks to Andy McMullan.
-o LOG4J2-1067: ThrowableProxy getExtendedStackTraceAsString throws NPE on deserialized nested exceptions. Thanks to Sam Braam.
-o LOG4J2-1049: AsyncAppender now resets the thread interrupted flag after catching InterruptedException. Thanks to Robert Schaft.
-o LOG4J2-1048: FileConfigurationMonitor unnecessarily calls System.currentTimeMillis() causing high CPU usage. Thanks to Nikhil.
-o LOG4J2-1037: Backward compatibility issue in log4j-1.2-api NDC pop() and peek(). Thanks to Marc Dergacz.
-o LOG4J2-1025: Custom java.util.logging.Level gives null Log4j Level and causes NPE. Thanks to Mikael Ståldal.
-o LOG4J2-1033: SimpleLogger creates unnecessary Map objects by calling ThreadContext.getContext() instead of getImmutableContext(). Thanks to Mikael Ståldal.
-o LOG4J2-1026: HighlightConverter does not obey noConsoleNoAnsi.
-o LOG4J2-1019: ZipCompressAction leaves files open until GC when an IO error takes place.
-o LOG4J2-1020: GzCompressAction leaves files open until GC when an IO error takes place.
-o LOG4J2-1038: Incorrect documentation for layout default charset. Thanks to Gili.
-o LOG4J2-1042: Socket and Syslog appenders don't take timeout into account at startup. Thanks to Guillaume Turri.
-o LOG4J2-934: Circular suppressed Exception throws StackOverflowError. Thanks to Kenneth Gendron.
-o LOG4J2-1046: Circular Exception cause throws StackOverflowError. Thanks to Kenneth Gendron.
-o LOG4J2-982: Use System.nanoTime() to measure time intervals. Thanks to Mikhail Mazurskiy.
-o LOG4J2-1045: Externalize log4j2.xml via URL resource. Thanks to Günter Albrecht.
-o LOG4J2-1058: Log4jMarker#contains(String) does not respect org.slf4j.Marker contract. Thanks to Daniel Branzea.
-o LOG4J2-1060: Log4jMarker#contains(Marker) does not respect org.slf4j.Marker contract.
-o LOG4J2-1061: Log4jMarker#remove(Marker) does not respect org.slf4j.Marker contract.
-o LOG4J2-1062: Log4jMarker#add(Marker) does not respect org.slf4j.Marker contract.
-o LOG4J2-1064: org.apache.logging.slf4j.Log4jMarker does not implement org.slf4j.Marker.equals(Object) org.slf4j.Marker.hashCode().
-o LOG4J2-889: Header in layout should not be written on application startup if appending to an existing file. Fixes LOG4J2-1030. Thanks to Maciej Karaś, Kenneth Leider.
-o LOG4J2-918: Clarify documentation for combining async with sync loggers.
-o LOG4J2-1078: GelfLayout throws exception if some log event fields are null. Thanks to Mikael Ståldal.
+o LOG4J2-1153: Fixed NullPointerException when only root logger is defined (and no named loggers) in configuration properties file.
+o LOG4J2-1140: Fixed bug where headers were not being written to first file with RollingFileAppender.
+o LOG4J2-1149: Fixed bug where PatternLayout predefined date pattern with time zone always renders default date format.
+o LOG4J2-1050: Fixed Log4jLookup.
+o LOG4J2-1142: Fix potential memory leak in web applications by using a straight ThreadLocal field instead of subclassing ThreadLocal.
+o LOG4J2-1135: Compression on rollover was broken: log file was renamed to .zip but not compressed.
+o LOG4J2-1127: log4j2.xml cannot be parsed on Oracle Weblogic 12c.
+o LOG4J2-1132: Do not use MongoDB driver 2.13.3 deprecated methods.
+o LOG4J2-1144: Add %markerSimpleName in pattern layout should evaluate to marker name (not toString()).
+o LOG4J2-1126: Web site corrections and updates.
Changes:
-o LOG4J2-1017: Update Java platform from Java 6 to 7. From this version onwards, log4j 2 requires Java 7.
-o LOG4J2-812: PatternLayout timestamp formatting performance improvement: replaced synchronized SimpleDateFormat with
- Apache Commons FastDateFormat. This and better caching resulted in a ~3-30X faster timestamp formatting.
-o LOG4J2-1097: PatternLayout timestamp formatting performance improvement: predefined date formats (and variants using
- a period '.' millisecond separator instead of ',') are now formatted ~2-10X faster than other date formats.
-o LOG4J2-1096: Improved performance of ParameterizedMessage::getFormattedMessage by ~2X.
-o LOG4J2-1120: LoggerConfig performance improvements: avoid unnecessary lock acquisition, use more efficient data structure.
-o LOG4J2-1125: PatternLayout performance improvement by caching and reusing a ThreadLocal StringBuilder.
-o LOG4J2-1114: Add thread name to status logger layout.
-o LOG4J2-1010: Pass log event when interpolating logger properties.
-o LOG4J2-1044: Support batchSize in FlumeAvroManager.
-o LOG4J2-1065: Define org.apache.logging.log4j.Marker.equals(Object) and org.apache.logging.log4j.Marker.hashCode().
-o LOG4J2-1063: Avoid creating temporary array object in org.apache.logging.slf4j.Log4jMarker.iterator().
-o LOG4J2-890: log4j-web-2.1 should workaround a bug in JBOSS EAP 6.2. Thanks to Hassan Kalaldeh, Robert Andersson, Remko Popma.
-o LOG4J2-403: MongoDB appender, username and password should be optional. Thanks to Poorna Subhash P, Jeremy Lautman.
-o LOG4J2-1035: Log4j2 tries to SystemClassLoader when running on Google AppEngine.
-o LOG4J2-1022: Allow a list of keys to be specified in the MDC pattern converter.
-o LOG4J2-959: Fix FindBugs DM_DEFAULT_ENCODING bug in SimpleLogger.logMessage() and simplify code.
-o LOG4J2-1036: Update Apache Flume from 1.5.2 to 1.6.0.
-o LOG4J2-1041: Update MongoDB driver from 2.11.2 to 2.13.2.
-o LOG4J2-1018: Update database tests from H2 1.3.175 to 1.3.176.
-o LOG4J2-1070: Update Java Mail from 1.5.2 to 1.5.4.
-o LOG4J2-1079: Update Jackson from 2.5.3 to 2.5.4.
-o LOG4J2-1879: Update Jackson from 2.5.4 to 2.6.0.
-o LOG4J2-1092: Update Jackson from 2.6.0 to 2.6.1.
-o LOG4J2-1104: Update Apache Commons Compress from 1.9 to 1.10.
+o LOG4J2-1151: Performance improvement: backport Java 8 fast ISO-8859-1 String to byte[] encoder to AbstractStringLayout.
+o LOG4J2-935: Performance improvement when converting Strings to byte[] arrays.
+o LOG4J2-1040: Update MongoDB driver from 2.13.3 to 3.0.4.
+o LOG4J2-1128: Reuse StringBuilder to improve performance for String-based layouts: CSV, GELF, HTML, RFC524, Syslog.
+o LOG4J2-1131: Update mongo-java-driver from 2.13.2 to 2.13.3.
+o LOG4J2-1138: Do not use Jackson deprecated methods.
+o LOG4J2-1139: Update Jackson from 2.6.1 to 2.6.2.
+o LOG4J2-1150: Update kafka-clients from 0.8.2.1 to 0.8.2.2.
-Removed:
-o Removed experimental interface LevelLogger which got committed to master by mistake.
-Apache Log4j 2.4 requires a minimum of Java 7 to build and run. Log4j 2.4 and greater requires Java 7,
+Apache Log4j 2.4.1 requires a minimum of Java 7 to build and run. Log4j 2.4 and greater requires Java 7,
version 2.3 required Java 6.
Basic compatibility with Log4j 1.x is provided through the log4j-1.2-api component, however it does not implement some of the
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/177aefef/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index bfad096..78dad40 100644
--- a/pom.xml
+++ b/pom.xml
@@ -164,8 +164,8 @@
<properties>
<!-- make sure to update these for each release! -->
<log4jParentDir>${basedir}</log4jParentDir>
- <Log4jReleaseVersion>2.4</Log4jReleaseVersion>
- <Log4jReleaseCount>eighth</Log4jReleaseCount>
+ <Log4jReleaseVersion>2.4.1</Log4jReleaseVersion>
+ <Log4jReleaseCount>ninth</Log4jReleaseCount>
<Log4jReleaseManager>Ralph Goers</Log4jReleaseManager>
<Log4jReleaseKey>B3D8E1BA</Log4jReleaseKey>
<!-- <Log4jReleaseManager>Matt Sicker</Log4jReleaseManager>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/177aefef/src/changes/announcement.vm
----------------------------------------------------------------------
diff --git a/src/changes/announcement.vm b/src/changes/announcement.vm
index a8d5599..fa38eba 100644
--- a/src/changes/announcement.vm
+++ b/src/changes/announcement.vm
@@ -26,8 +26,8 @@ Log4j that provides significant improvements over its predecessor, Log4j 1.x, an
many other modern features such as support for Markers, property substitution using Lookups, and asynchronous
Loggers. In addition, Log4j 2 will not lose events while reconfiguring.
-This is the ${relCount} GA release. It contains several bugfixes and new features. As of this release
-Log4j now requires a minimum of Java 7.
+This is the ${relCount} GA release. It contains several bugfixes and new features.
+Log4j 2 requires a minimum of Java 7.
## Hack to improve layout: replace all pairs of spaces with a single new-line
$release.description.replaceAll(" ", "
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/177aefef/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index ab6a089..e250e6e 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -23,15 +23,15 @@
<title>Changes</title>
</properties>
<body>
- <release version="2.4.1" date="2015-MM-DD" description="GA Release 2.4.1">
+ <release version="2.4.1" date="2015-10-08" description="GA Release 2.4.1">
<action issue="LOG4J2-1129" dev="rgoers" type="add">
Allow PatternLayout to select a pattern to use based on some selection criteria.
</action>
<action issue="LOG4J2-1145" dev="ggregory" type="add">
- Add %equals to PatternLayout to test and replace patterns with strings.
+ Add %equals to PatternLayout to test and replace patterns with strings.
</action>
<action issue="LOG4J2-1147" dev="ggregory" type="add">
- Add %equalsIgnoreCase to PatternLayout to test and replace patterns with strings.
+ Add %equalsIgnoreCase to PatternLayout to test and replace patterns with strings.
</action>
<action issue="LOG4J2-1146" dev="ggregory" type="add">
Add %notEmpty to PatternLayout to avoid output of patterns where all variables are empty.
@@ -86,13 +86,13 @@
</action>
<action issue="LOG4J2-1138" dev="ggregory" type="update">
Do not use Jackson deprecated methods.
- </action>
+ </action>
<action issue="LOG4J2-1139" dev="ggregory" type="update">
Update Jackson from 2.6.1 to 2.6.2.
- </action>
+ </action>
<action issue="LOG4J2-1150" dev="ggregory" type="update">
Update kafka-clients from 0.8.2.1 to 0.8.2.2.
- </action>
+ </action>
</release>
<release version="2.4" date="2015-09-20" description="GA Release 2.4">
<action issue="LOG4J2-635" dev="rgoers" type="add">
[17/27] logging-log4j2 git commit: LOG4J2-935 added comment to
explain unusual logic
Posted by rg...@apache.org.
LOG4J2-935 added comment to explain unusual logic
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/ec8fd28f
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/ec8fd28f
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/ec8fd28f
Branch: refs/heads/LOG4J2-1136
Commit: ec8fd28fc52fa86d2ff229bb3f1e21eb1450a811
Parents: 2238958
Author: rpopma <rp...@apache.org>
Authored: Mon Oct 5 12:25:36 2015 +0200
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Sun Oct 11 12:40:43 2015 -0700
----------------------------------------------------------------------
.../apache/logging/log4j/core/layout/AbstractStringLayout.java | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ec8fd28f/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
index de73e27..ae6f4c2 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
@@ -25,6 +25,10 @@ import org.apache.logging.log4j.core.LogEvent;
/**
* Abstract base class for Layouts that result in a String.
*/
+/*
+ * Implementation note: prefer String.getBytes(String) to String.getBytes(Charset) for performance reasons.
+ * See https://issues.apache.org/jira/browse/LOG4J2-935 for details.
+ */
public abstract class AbstractStringLayout extends AbstractLayout<String> {
/**
[11/27] logging-log4j2 git commit: Use built-in UTF-8 Charset.
Posted by rg...@apache.org.
Use built-in UTF-8 Charset.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/6f57c581
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/6f57c581
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/6f57c581
Branch: refs/heads/LOG4J2-1136
Commit: 6f57c58190b9615489ae997f3d6db32bd4c68eca
Parents: ce419dc
Author: ggregory <gg...@apache.org>
Authored: Mon Oct 5 12:02:10 2015 -0700
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Sun Oct 11 12:40:43 2015 -0700
----------------------------------------------------------------------
.../logging/log4j/flume/appender/FlumePersistentManager.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/6f57c581/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumePersistentManager.java
----------------------------------------------------------------------
diff --git a/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumePersistentManager.java b/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumePersistentManager.java
index 3383d79..15ce921 100644
--- a/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumePersistentManager.java
+++ b/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumePersistentManager.java
@@ -22,6 +22,7 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Callable;
@@ -68,7 +69,7 @@ public class FlumePersistentManager extends FlumeAvroManager {
/** Attribute name for the key provider. */
public static final String KEY_PROVIDER = "keyProvider";
- private static final Charset UTF8 = Charset.forName("UTF-8");
+ private static final Charset UTF8 = StandardCharsets.UTF_8;
private static final String DEFAULT_DATA_DIR = ".log4j/flumeData";
[13/27] logging-log4j2 git commit: LOG4J2-935: document reason for
this logic in comments
Posted by rg...@apache.org.
LOG4J2-935: document reason for this logic in comments
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2b967424
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2b967424
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2b967424
Branch: refs/heads/LOG4J2-1136
Commit: 2b967424f6fdb04894b9cb7af51aa171bee33522
Parents: 6630dd7
Author: rpopma <rp...@apache.org>
Authored: Mon Oct 5 02:00:43 2015 +0200
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Sun Oct 11 12:40:43 2015 -0700
----------------------------------------------------------------------
.../apache/logging/log4j/core/layout/AbstractStringLayout.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2b967424/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
index 3a5d39b..de73e27 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
@@ -63,7 +63,7 @@ public abstract class AbstractStringLayout extends AbstractLayout<String> {
static byte[] toBytes(final String str, final Charset charset) {
if (str != null) {
final Charset actual = charset != null ? charset : Charset.defaultCharset();
- try {
+ try { // LOG4J2-935: String.getBytes(String) gives better performance
return str.getBytes(actual.name());
} catch (UnsupportedEncodingException e) {
return str.getBytes(actual);
@@ -88,7 +88,7 @@ public abstract class AbstractStringLayout extends AbstractLayout<String> {
}
protected byte[] getBytes(final String s) {
- try {
+ try { // LOG4J2-935: String.getBytes(String) gives better performance
return s.getBytes(charsetName);
} catch (UnsupportedEncodingException e) {
return s.getBytes(charset);
[15/27] logging-log4j2 git commit: LOG4J2-1151 updated: added exact
port of JDK 8 logic for handling invalid input, renamed methods
Posted by rg...@apache.org.
LOG4J2-1151 updated: added exact port of JDK 8 logic for handling
invalid input, renamed methods
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/1d1c5d17
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/1d1c5d17
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/1d1c5d17
Branch: refs/heads/LOG4J2-1136
Commit: 1d1c5d1759a633104c9a45fa5d2b7eaf75be2461
Parents: 4bc743e
Author: rpopma <rp...@apache.org>
Authored: Tue Oct 6 01:14:18 2015 +0200
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Sun Oct 11 12:40:43 2015 -0700
----------------------------------------------------------------------
.../log4j/perf/jmh/StringEncodingBenchmark.java | 151 +++++++++++++++++--
1 file changed, 137 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/1d1c5d17/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/StringEncodingBenchmark.java
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/StringEncodingBenchmark.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/StringEncodingBenchmark.java
index 4159b2a..7e9459c 100644
--- a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/StringEncodingBenchmark.java
+++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/StringEncodingBenchmark.java
@@ -35,7 +35,7 @@ import org.openjdk.jmh.annotations.State;
* Tests Log4j2 StringEncoding performance.
*/
// ============================== HOW TO RUN THIS TEST: ====================================
-//(Quick build: mvn -DskipTests=true clean package -pl log4j-perf -am )
+// (Quick build: mvn -DskipTests=true clean package -pl log4j-perf -am )
//
// java -jar log4j-perf/target/benchmarks.jar ".*StringEncoding.*" -f 1 -wi 5 -i 10
//
@@ -63,70 +63,70 @@ public class StringEncodingBenchmark {
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
- public byte[] stringGetBytes() {
+ public byte[] defaultStringGetBytes() {
return LOGMSG.getBytes();
}
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
- public byte[] stringGetBytesString88591() throws Exception {
+ public byte[] iso8859_1StringGetBytesString() throws Exception {
return LOGMSG.getBytes(STRING_ISO8859_1);
}
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
- public byte[] stringGetBytesCharSet88591() {
+ public byte[] iso8859_1StringGetBytesCharSet() {
return LOGMSG.getBytes(CHARSET_ISO8859_1);
}
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
- public byte[] stringGetBytesStringUsAscii() throws Exception {
+ public byte[] usAsciiStringGetBytesString() throws Exception {
return LOGMSG.getBytes(STRING_US_ASCII);
}
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
- public byte[] stringGetBytesCharSetUsAscii() {
+ public byte[] usAsciiStringGetBytesCharSet() {
return LOGMSG.getBytes(CHARSET_US_ASCII);
}
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
- public byte[] stringGetBytesStringDefault() throws Exception {
+ public byte[] defaultStringGetBytesString() throws Exception {
return LOGMSG.getBytes(DEFAULT_ENCODING);
}
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
- public byte[] stringGetBytesCharSetDefault() {
+ public byte[] defaultStringGetBytesCharSet() {
return LOGMSG.getBytes(CHARSET_DEFAULT);
}
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
- public byte[] stringGetBytesStringShiftJIS() throws Exception {
+ public byte[] shiftJisStringGetBytesString() throws Exception {
return LOGMSG.getBytes(STRING_SHIFT_JIS);
}
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
- public byte[] stringGetBytesCharSetShiftJIS() {
+ public byte[] shiftJisStringGetBytesCharSet() {
return LOGMSG.getBytes(CHARSET_SHIFT_JIS);
}
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
- public byte[] encoderShiftJIS() throws CharacterCodingException {
+ public byte[] shiftJisEncoder() throws CharacterCodingException {
ByteBuffer buf = ENCODER_SHIFT_JIS.encode(CharBuffer.wrap(LOGMSG));
return buf.array();
}
@@ -134,7 +134,7 @@ public class StringEncodingBenchmark {
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
- public byte[] encoderIso8859_1() throws CharacterCodingException {
+ public byte[] iso8859_1Encoder() throws CharacterCodingException {
ByteBuffer buf = ENCODER_ISO8859_1.encode(CharBuffer.wrap(LOGMSG));
return buf.array();
}
@@ -142,12 +142,135 @@ public class StringEncodingBenchmark {
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
- public byte[] customIso8859_1() throws CharacterCodingException {
+ public byte[] iso8859_1CustomCastToByte() throws CharacterCodingException {
final int length = LOGMSG.length();
final byte[] result = new byte[length];
for (int i = 0; i < length; i++) {
- result[i] = (byte) LOGMSG.charAt(i);
+ final char c = LOGMSG.charAt(i);
+ result[i++] = (byte) c;
}
return result;
}
+
+ @Benchmark
+ @BenchmarkMode(Mode.SampleTime)
+ @OutputTimeUnit(TimeUnit.NANOSECONDS)
+ public byte[] iso8859_1CustomVerifyAndCast() throws CharacterCodingException {
+ final int length = LOGMSG.length();
+ final byte[] result = new byte[length];
+ int j = 0;
+ for (int i = 0; i < length; i++) {
+ final char c = LOGMSG.charAt(i);
+ if (c <= 255) {
+ result[j++] = (byte) c;
+ } else {
+ i = nonIsoChar(LOGMSG, i);
+ result[j++] = (byte) '?';
+ }
+ }
+ return result;
+ }
+
+ private int nonIsoChar(String logmsg, int i) {
+ char c = logmsg.charAt(i++);
+ if ((Character.isHighSurrogate(c)) && (i < logmsg.length()) && (Character.isLowSurrogate(logmsg.charAt(i)))) {
+ i++;
+ }
+ return i;
+ }
+
+ @Benchmark
+ @BenchmarkMode(Mode.SampleTime)
+ @OutputTimeUnit(TimeUnit.NANOSECONDS)
+ public byte[] iso8859_1CustomPortedJDK8() throws CharacterCodingException {
+ final int length = LOGMSG.length();
+ final byte[] result = new byte[length];
+ encode(LOGMSG, 0, length, result);
+ return result;
+ }
+
+ private static int encodeISOArray(String charArray, int charIndex, byte[] byteArray, int byteIndex, int length) {
+ int i = 0;
+ for (; i < length; i++) {
+ char c = charArray.charAt(charIndex++);
+ if (c > 255) {
+ break;
+ }
+ byteArray[(byteIndex++)] = ((byte) c);
+ }
+ return i;
+ }
+
+ private int encode(String charArray, int charOffset, int charLength, byte[] byteArray) {
+ int offset = 0;
+ int length = Math.min(charLength, byteArray.length);
+ int charDoneIndex = charOffset + length;
+ while (charOffset < charDoneIndex) {
+ int m = encodeISOArray(charArray, charOffset, byteArray, offset, length);
+ charOffset += m;
+ offset += m;
+ if (m != length) {
+ char c = charArray.charAt(charOffset++);
+ if ((Character.isHighSurrogate(c)) && (charOffset < charDoneIndex)
+ && (Character.isLowSurrogate(charArray.charAt(charOffset)))) {
+ if (charLength > byteArray.length) {
+ charDoneIndex++;
+ charLength--;
+ }
+ charOffset++;
+ }
+ byteArray[(offset++)] = '?';
+ length = Math.min(charDoneIndex - charOffset, byteArray.length - offset);
+ }
+ }
+ return offset;
+ }
+
+ @Benchmark
+ @BenchmarkMode(Mode.SampleTime)
+ @OutputTimeUnit(TimeUnit.NANOSECONDS)
+ public byte[] iso8859_1CustomPortedJDK8CopyArray() throws CharacterCodingException {
+ char[] charArray = LOGMSG.toCharArray();
+ final int length = charArray.length;
+ final byte[] result = new byte[length];
+ encode0(charArray, 0, length, result);
+ return result;
+ }
+
+ private static int encodeISOArray0(char[] charArray, int charIndex, byte[] byteArray, int byteIndex, int length) {
+ int i = 0;
+ for (; i < length; i++) {
+ char c = charArray[(charIndex++)];
+ if (c > 255) {
+ break;
+ }
+ byteArray[(byteIndex++)] = ((byte) c);
+ }
+ return i;
+ }
+
+ private int encode0(char[] charArray, int charOffset, int charLength, byte[] byteArray) {
+ int offset = 0;
+ int length = Math.min(charLength, byteArray.length);
+ int charDoneIndex = charOffset + length;
+ while (charOffset < charDoneIndex) {
+ int m = encodeISOArray0(charArray, charOffset, byteArray, offset, length);
+ charOffset += m;
+ offset += m;
+ if (m != length) {
+ char c = charArray[(charOffset++)];
+ if ((Character.isHighSurrogate(c)) && (charOffset < charDoneIndex)
+ && (Character.isLowSurrogate(charArray[(charOffset)]))) {
+ if (charLength > byteArray.length) {
+ charDoneIndex++;
+ charLength--;
+ }
+ charOffset++;
+ }
+ byteArray[(offset++)] = '?';
+ length = Math.min(charDoneIndex - charOffset, byteArray.length - offset);
+ }
+ }
+ return offset;
+ }
}
[22/27] logging-log4j2 git commit: fixed wrong default values in docs
for PatternLayout charset and %d; language nits
Posted by rg...@apache.org.
fixed wrong default values in docs for PatternLayout charset and %d;
language nits
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/efa2c82a
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/efa2c82a
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/efa2c82a
Branch: refs/heads/LOG4J2-1136
Commit: efa2c82a91570fd1054e3ac345bc973c89fa17db
Parents: c539c17
Author: rpopma <rp...@apache.org>
Authored: Tue Oct 6 15:34:12 2015 +0200
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Sun Oct 11 12:40:44 2015 -0700
----------------------------------------------------------------------
src/site/xdoc/manual/layouts.xml.vm | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/efa2c82a/src/site/xdoc/manual/layouts.xml.vm
----------------------------------------------------------------------
diff --git a/src/site/xdoc/manual/layouts.xml.vm b/src/site/xdoc/manual/layouts.xml.vm
index 8ec444c..e29de73 100644
--- a/src/site/xdoc/manual/layouts.xml.vm
+++ b/src/site/xdoc/manual/layouts.xml.vm
@@ -46,12 +46,12 @@
</p>
<p>
The root class for layouts that use a Charset is <code>org.apache.logging.log4j.core.layout.AbstractStringLayout</code>
- where the default there is UTF-8. Each layout that extends <code>org.apache.logging.log4j.core.layout.AbstractStringLayout</code>
+ where the default is UTF-8. Each layout that extends <code>org.apache.logging.log4j.core.layout.AbstractStringLayout</code>
can provide its own default. See each layout below.
</p>
<p>
A custom character encoder was added to Log4j 2.4.1 for the ISO-8859-1 and US-ASCII charsets,
- backporting the performance improvements built-in to Java 8 to Log4j for use on Java 7.
+ to bring some of the performance improvements built-in to Java 8 to Log4j for use on Java 7.
For applications that log only ISO-8859-1 characters, specifying this charset will improve performance significantly.
</p>
<a name="CSVLayouts"/>
@@ -401,7 +401,7 @@ WARN [main]: Message 2</pre>
<td>charset</td>
<td>String</td>
<td>The character set to use when converting the syslog String to a byte array. The String must be
- a valid ${Charset}. If not specified, this layout uses UTF-8.
+ a valid ${Charset}. If not specified, this layout uses the platform default character set.
</td>
</tr>
<tr>
@@ -557,7 +557,7 @@ WARN [main]: Message 2</pre>
</p>
<p>You can also use a set of braces containing a time zone id per
<a class="javadoc" href="${javadocRoot}/java/util/TimeZone.html${sharp}getTimeZone(java.lang.String)">
- java.util.TimeZone.getTimeZone</a>. 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 the DEFAULT format is used.
<table>
<tr>
<th>Pattern</th>
[03/27] logging-log4j2 git commit: Checkstyle: declaration order,
source format
Posted by rg...@apache.org.
Checkstyle: declaration order, source format
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/dbc5d435
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/dbc5d435
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/dbc5d435
Branch: refs/heads/LOG4J2-1136
Commit: dbc5d435c1bd304ed71cde5164210c7401c92db6
Parents: 558dbbb
Author: rpopma <rp...@apache.org>
Authored: Sun Oct 4 23:36:35 2015 +0200
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Sun Oct 11 12:40:42 2015 -0700
----------------------------------------------------------------------
.../core/pattern/DatePatternConverter.java | 57 +++++++++-----------
1 file changed, 26 insertions(+), 31 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/dbc5d435/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/DatePatternConverter.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/DatePatternConverter.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/DatePatternConverter.java
index 230cfe4..8af403b 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/DatePatternConverter.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/DatePatternConverter.java
@@ -31,21 +31,9 @@ import org.apache.logging.log4j.core.util.datetime.FixedDateFormat.FixedFormat;
* Converts and formats the event's date in a StringBuilder.
*/
@Plugin(name = "DatePatternConverter", category = PatternConverter.CATEGORY)
-@ConverterKeys({ "d", "date" })
+@ConverterKeys({"d", "date"})
public final class DatePatternConverter extends LogEventPatternConverter implements ArrayPatternConverter {
- private final class CachedTime {
- public long timestampMillis;
- public String formatted;
-
- public CachedTime(final long timestampMillis) {
- this.timestampMillis = timestampMillis;
- this.formatted = formatter.format(this.timestampMillis);
- }
- }
-
- private final AtomicReference<CachedTime> cachedTime;
-
private abstract static class Formatter {
abstract String format(long timeMillis);
@@ -106,6 +94,16 @@ public final class DatePatternConverter extends LogEventPatternConverter impleme
}
}
+ private final class CachedTime {
+ public long timestampMillis;
+ public String formatted;
+
+ public CachedTime(final long timestampMillis) {
+ this.timestampMillis = timestampMillis;
+ this.formatted = formatter.format(this.timestampMillis);
+ }
+ }
+
/**
* UNIX formatter in seconds (standard).
*/
@@ -116,24 +114,13 @@ public final class DatePatternConverter extends LogEventPatternConverter impleme
*/
private static final String UNIX_MILLIS_FORMAT = "UNIX_MILLIS";
- /**
- * Obtains an instance of pattern converter.
- *
- * @param options
- * options, may be null.
- * @return instance of pattern converter.
- */
- public static DatePatternConverter newInstance(final String[] options) {
- return new DatePatternConverter(options);
- }
-
+ private final AtomicReference<CachedTime> cachedTime;
private final Formatter formatter;
/**
* Private constructor.
*
- * @param options
- * options, may be null.
+ * @param options options, may be null.
*/
private DatePatternConverter(final String[] options) {
super("Date", "date");
@@ -147,6 +134,16 @@ public final class DatePatternConverter extends LogEventPatternConverter impleme
cachedTime = new AtomicReference<>(new CachedTime(System.currentTimeMillis()));
}
+ /**
+ * Obtains an instance of pattern converter.
+ *
+ * @param options options, may be null.
+ * @return instance of pattern converter.
+ */
+ public static DatePatternConverter newInstance(final String[] options) {
+ return new DatePatternConverter(options);
+ }
+
private static Formatter createFormatter(final FixedDateFormat fixedDateFormat) {
return new FixedFormatter(fixedDateFormat);
}
@@ -189,10 +186,8 @@ public final class DatePatternConverter extends LogEventPatternConverter impleme
/**
* Appends formatted date to string buffer.
*
- * @param date
- * date
- * @param toAppendTo
- * buffer to which formatted date is appended.
+ * @param date date
+ * @param toAppendTo buffer to which formatted date is appended.
*/
public void format(final Date date, final StringBuilder toAppendTo) {
format(date.getTime(), toAppendTo);
@@ -205,7 +200,7 @@ public final class DatePatternConverter extends LogEventPatternConverter impleme
public void format(final LogEvent event, final StringBuilder output) {
format(event.getTimeMillis(), output);
}
-
+
public void format(final long timestampMillis, final StringBuilder output) {
CachedTime cached = cachedTime.get();
if (timestampMillis != cached.timestampMillis) {
[14/27] logging-log4j2 git commit: LOG4J2-1151: bugfixes and doc
improvement
Posted by rg...@apache.org.
LOG4J2-1151: bugfixes and doc improvement
- use JDK 8 built-in encoder if available
- on Java 7, use JDK 8 backported logic to handle invalid input
- layout manual documentation improvement
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/3ca1bfd6
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/3ca1bfd6
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/3ca1bfd6
Branch: refs/heads/LOG4J2-1136
Commit: 3ca1bfd6223ecb3e826dbbdc354c74ba091de517
Parents: 1d1c5d1
Author: rpopma <rp...@apache.org>
Authored: Tue Oct 6 01:39:48 2015 +0200
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Sun Oct 11 12:40:43 2015 -0700
----------------------------------------------------------------------
.../log4j/core/layout/AbstractStringLayout.java | 63 +++++++++++++++++---
src/site/xdoc/manual/layouts.xml.vm | 4 +-
2 files changed, 58 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3ca1bfd6/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
index d48ee00..bb4ad1c 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
@@ -49,7 +49,7 @@ public abstract class AbstractStringLayout extends AbstractLayout<String> {
// TODO: Charset is not serializable. Implement read/writeObject() ?
private final Charset charset;
private final String charsetName;
- private final boolean isDirectSingleByteMapping;
+ private final boolean useCustomEncoding;
protected AbstractStringLayout(final Charset charset) {
this(charset, null, null);
@@ -59,8 +59,20 @@ public abstract class AbstractStringLayout extends AbstractLayout<String> {
super(header, footer);
this.charset = charset == null ? StandardCharsets.UTF_8 : charset;
this.charsetName = this.charset.name();
- isDirectSingleByteMapping = StandardCharsets.ISO_8859_1.equals(charset)
- || StandardCharsets.US_ASCII.equals(charset);
+ useCustomEncoding = isPreJava8()
+ && (StandardCharsets.ISO_8859_1.equals(charset) || StandardCharsets.US_ASCII.equals(charset));
+ }
+
+ // LOG4J2-1151: If the built-in JDK 8 encoders are available we should use them.
+ private static boolean isPreJava8() {
+ final String version = System.getProperty("java.version");
+ final String[] parts = version.split("\\.");
+ try {
+ int major = Integer.parseInt(parts[1]);
+ return major < 8;
+ } catch (Exception ex) {
+ return true;
+ }
}
/**
@@ -101,7 +113,7 @@ public abstract class AbstractStringLayout extends AbstractLayout<String> {
}
protected byte[] getBytes(final String s) {
- if (isDirectSingleByteMapping) { // rely on branch prediction to eliminate this check if false
+ if (useCustomEncoding) { // rely on branch prediction to eliminate this check if false
return encodeSingleByteChars(s);
}
try { // LOG4J2-935: String.getBytes(String) gives better performance
@@ -121,12 +133,49 @@ public abstract class AbstractStringLayout extends AbstractLayout<String> {
private static byte[] encodeSingleByteChars(String s) {
final int length = s.length();
final byte[] result = new byte[length];
- for (int i = 0; i < length; i++) {
- result[i] = (byte) s.charAt(i);
- }
+ encode(s, 0, length, result);
return result;
}
+ // LOG4J2-1151
+ private static int encodeISOArray(String charArray, int charIndex, byte[] byteArray, int byteIndex, int length) {
+ int i = 0;
+ for (; i < length; i++) {
+ char c = charArray.charAt(charIndex++);
+ if (c > 255) {
+ break;
+ }
+ byteArray[(byteIndex++)] = ((byte) c);
+ }
+ return i;
+ }
+
+ // LOG4J2-1151
+ private static int encode(String charArray, int charOffset, int charLength, byte[] byteArray) {
+ int offset = 0;
+ int length = Math.min(charLength, byteArray.length);
+ int charDoneIndex = charOffset + length;
+ while (charOffset < charDoneIndex) {
+ int m = encodeISOArray(charArray, charOffset, byteArray, offset, length);
+ charOffset += m;
+ offset += m;
+ if (m != length) {
+ char c = charArray.charAt(charOffset++);
+ if ((Character.isHighSurrogate(c)) && (charOffset < charDoneIndex)
+ && (Character.isLowSurrogate(charArray.charAt(charOffset)))) {
+ if (charLength > byteArray.length) {
+ charDoneIndex++;
+ charLength--;
+ }
+ charOffset++;
+ }
+ byteArray[(offset++)] = '?';
+ length = Math.min(charDoneIndex - charOffset, byteArray.length - offset);
+ }
+ }
+ return offset;
+ }
+
protected Charset getCharset() {
return charset;
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3ca1bfd6/src/site/xdoc/manual/layouts.xml.vm
----------------------------------------------------------------------
diff --git a/src/site/xdoc/manual/layouts.xml.vm b/src/site/xdoc/manual/layouts.xml.vm
index 6075b6a..8ec444c 100644
--- a/src/site/xdoc/manual/layouts.xml.vm
+++ b/src/site/xdoc/manual/layouts.xml.vm
@@ -51,8 +51,8 @@
</p>
<p>
A custom character encoder was added to Log4j 2.4.1 for the ISO-8859-1 and US-ASCII charsets,
- backporting the performance improvements from Java 8 for use on Java 7.
- For applications that log only ISO-8859-1 characters, specifying this charset will improve performance.
+ backporting the performance improvements built-in to Java 8 to Log4j for use on Java 7.
+ For applications that log only ISO-8859-1 characters, specifying this charset will improve performance significantly.
</p>
<a name="CSVLayouts"/>
<subsection name="CSV Layouts">
[20/27] logging-log4j2 git commit: LOG4J2-1151 better variable and
method names, added comment
Posted by rg...@apache.org.
LOG4J2-1151 better variable and method names, added comment
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/8c1bb39d
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/8c1bb39d
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/8c1bb39d
Branch: refs/heads/LOG4J2-1136
Commit: 8c1bb39d975cc7b7ad24e685b86cfc8c170c44c6
Parents: efa2c82
Author: rpopma <rp...@apache.org>
Authored: Tue Oct 6 16:09:53 2015 +0200
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Sun Oct 11 12:40:44 2015 -0700
----------------------------------------------------------------------
.../log4j/core/layout/AbstractStringLayout.java | 26 +++++++++++---------
1 file changed, 15 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8c1bb39d/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
index bb4ad1c..c928d62 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
@@ -133,12 +133,16 @@ public abstract class AbstractStringLayout extends AbstractLayout<String> {
private static byte[] encodeSingleByteChars(String s) {
final int length = s.length();
final byte[] result = new byte[length];
- encode(s, 0, length, result);
+ encodeString(s, 0, length, result);
return result;
}
// LOG4J2-1151
- private static int encodeISOArray(String charArray, int charIndex, byte[] byteArray, int byteIndex, int length) {
+ /*
+ * Implementation note: this is the fast path. If the char array contains only ISO-8859-1 characters, all the work
+ * will be done here.
+ */
+ private static int encodeIsoChars(String charArray, int charIndex, byte[] byteArray, int byteIndex, int length) {
int i = 0;
for (; i < length; i++) {
char c = charArray.charAt(charIndex++);
@@ -151,15 +155,15 @@ public abstract class AbstractStringLayout extends AbstractLayout<String> {
}
// LOG4J2-1151
- private static int encode(String charArray, int charOffset, int charLength, byte[] byteArray) {
- int offset = 0;
+ private static int encodeString(String charArray, int charOffset, int charLength, byte[] byteArray) {
+ int byteOffset = 0;
int length = Math.min(charLength, byteArray.length);
int charDoneIndex = charOffset + length;
while (charOffset < charDoneIndex) {
- int m = encodeISOArray(charArray, charOffset, byteArray, offset, length);
- charOffset += m;
- offset += m;
- if (m != length) {
+ int done = encodeIsoChars(charArray, charOffset, byteArray, byteOffset, length);
+ charOffset += done;
+ byteOffset += done;
+ if (done != length) {
char c = charArray.charAt(charOffset++);
if ((Character.isHighSurrogate(c)) && (charOffset < charDoneIndex)
&& (Character.isLowSurrogate(charArray.charAt(charOffset)))) {
@@ -169,11 +173,11 @@ public abstract class AbstractStringLayout extends AbstractLayout<String> {
}
charOffset++;
}
- byteArray[(offset++)] = '?';
- length = Math.min(charDoneIndex - charOffset, byteArray.length - offset);
+ byteArray[(byteOffset++)] = '?';
+ length = Math.min(charDoneIndex - charOffset, byteArray.length - byteOffset);
}
}
- return offset;
+ return byteOffset;
}
protected Charset getCharset() {
[21/27] logging-log4j2 git commit: LOG4J2-1153: Fixed
NullPointerException when only root logger is defined (and no named loggers)
in configuration properties file.
Posted by rg...@apache.org.
LOG4J2-1153: Fixed NullPointerException when only root logger is defined
(and no named loggers) in configuration properties file.
- bugfix in PropertiesConfigurationFactory
- removed unnecessary @SuppressWarnings annotation
- added JUnit test demonstrating the issue and proving that the fix
works
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/8acedb4e
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/8acedb4e
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/8acedb4e
Branch: refs/heads/LOG4J2-1136
Commit: 8acedb4e7718ad6ac6ddb648143bfbb1aa10fa83
Parents: 8c1bb39
Author: rpopma <rp...@apache.org>
Authored: Tue Oct 6 16:30:08 2015 +0200
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Sun Oct 11 12:40:44 2015 -0700
----------------------------------------------------------------------
.../PropertiesConfigurationFactory.java | 3 +-
...opertiesConfigurationRootLoggerOnlyTest.java | 60 ++++++++++++++++++++
.../log4j2-properties-root-only.properties | 38 +++++++++++++
src/changes/changes.xml | 3 +
4 files changed, 102 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8acedb4e/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationFactory.java
index 58094f0..6be8683 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationFactory.java
@@ -151,7 +151,7 @@ public class PropertiesConfigurationFactory extends ConfigurationFactory {
}
}
String loggerProp = properties.getProperty("loggers");
- if (appenderProp != null) {
+ if (loggerProp != null) {
String[] loggerNames = loggerProp.split(",");
for (String loggerName : loggerNames) {
String name = loggerName.trim();
@@ -400,7 +400,6 @@ public class PropertiesConfigurationFactory extends ConfigurationFactory {
return componentBuilder;
}
- @SuppressWarnings({"unchecked", "rawtypes"})
private void processRemainingProperties(ComponentBuilder<?> builder, String name, Properties properties) {
while (properties.size() > 0) {
String propertyName = properties.stringPropertyNames().iterator().next();
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8acedb4e/log4j-core/src/test/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationRootLoggerOnlyTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationRootLoggerOnlyTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationRootLoggerOnlyTest.java
new file mode 100644
index 0000000..88b0709
--- /dev/null
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationRootLoggerOnlyTest.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.config.properties;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.Appender;
+import org.apache.logging.log4j.core.Filter;
+import org.apache.logging.log4j.core.LifeCycle;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.config.Configuration;
+import org.apache.logging.log4j.core.config.ConfigurationFactory;
+import org.apache.logging.log4j.core.config.LoggerConfig;
+import org.apache.logging.log4j.core.filter.ThresholdFilter;
+import org.junit.Test;
+
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ *
+ */
+public class PropertiesConfigurationRootLoggerOnlyTest {
+
+ @Test
+ public void testPropertiesConfiguration() {
+ System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "target/test-classes/log4j2-properties-root-only.properties");
+ Configuration config = ((LoggerContext)LogManager.getContext(false)).getConfiguration();
+ assertNotNull("No configuration created", config);
+ assertEquals("Incorrect State: " + config.getState(), config.getState(), LifeCycle.State.STARTED);
+ Map<String, Appender> appenders = config.getAppenders();
+ assertNotNull(appenders);
+ assertTrue("Incorrect number of Appenders: " + appenders.size(), appenders.size() == 1);
+ Map<String, LoggerConfig> loggers = config.getLoggers();
+ assertNotNull(loggers);
+ assertTrue("Incorrect number of LoggerConfigs: " + loggers.size(), loggers.size() == 1);
+ Filter filter = config.getFilter();
+ assertNotNull("No Filter", filter);
+ assertTrue("Not a Threshold Filter", filter instanceof ThresholdFilter);
+ Logger logger = LogManager.getLogger(getClass());
+ logger.info("Welcome to Log4j!");
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8acedb4e/log4j-core/src/test/resources/log4j2-properties-root-only.properties
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/resources/log4j2-properties-root-only.properties b/log4j-core/src/test/resources/log4j2-properties-root-only.properties
new file mode 100644
index 0000000..7587606
--- /dev/null
+++ b/log4j-core/src/test/resources/log4j2-properties-root-only.properties
@@ -0,0 +1,38 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+status = ERROR
+
+filters = Threshold
+
+filter.Threshold.type = ThresholdFilter
+filter.Threshold.level = DEBUG
+
+appenders = Stdout
+
+appender.Stdout.type = Console
+appender.Stdout.name = StdOut
+appender.Stdout.target = SYSTEM_OUT
+appender.Stdout.layout.type = PatternLayout
+appender.Stdout.layout.pattern = %d [%t] %-5level: %msg%n%throwable
+appender.Stdout.filters = marker
+appender.Stdout.filter.marker.type = MarkerFilter
+appender.Stdout.filter.marker.onMatch = DENY
+appender.Stdout.filter.marker.onMisMatch = NEUTRAL
+appender.Stdout.filter.marker.marker = FLOW
+
+rootLogger.appenderRefs = console
+rootLogger.appenderRef.console.ref = StdOut
+rootLogger.level = ERROR
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8acedb4e/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index f7f5df1..ab6a089 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -39,6 +39,9 @@
<action issue="LOG4J2-1020" dev="mikes" type="add">
Add possibility to set shutdown timeout on AsyncAppender.
</action>
+ <action issue="LOG4J2-1153" dev="rpopma" type="fix">
+ Fixed NullPointerException when only root logger is defined (and no named loggers) in configuration properties file.
+ </action>
<action issue="LOG4J2-1140" dev="rpopma" type="fix">
Fixed bug where headers were not being written to first file with RollingFileAppender.
</action>
[19/27] logging-log4j2 git commit: [LOG4J2-1150] Update kafka-clients
from 0.8.2.1 to 0.8.2.2.
Posted by rg...@apache.org.
[LOG4J2-1150] Update kafka-clients from 0.8.2.1 to 0.8.2.2.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/22389588
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/22389588
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/22389588
Branch: refs/heads/LOG4J2-1136
Commit: 22389588963d542b4edb824fa7eb5cc45b7c7c6f
Parents: 5e246db
Author: ggregory <gg...@apache.org>
Authored: Sun Oct 4 21:13:19 2015 -0700
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Sun Oct 11 12:40:43 2015 -0700
----------------------------------------------------------------------
pom.xml | 2 +-
src/changes/changes.xml | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/22389588/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 1df54f4..bfad096 100644
--- a/pom.xml
+++ b/pom.xml
@@ -572,7 +572,7 @@
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
- <version>0.8.2.1</version>
+ <version>0.8.2.2</version>
</dependency>
<dependency>
<groupId>org.zeromq</groupId>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/22389588/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 1ab8b9f..7195f1f 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -84,6 +84,9 @@
<action issue="LOG4J2-1139" dev="ggregory" type="update">
Update Jackson from 2.6.1 to 2.6.2.
</action>
+ <action issue="LOG4J2-1150" dev="ggregory" type="update">
+ Update kafka-clients from 0.8.2.1 to 0.8.2.2.
+ </action>
</release>
<release version="2.4" date="2015-09-20" description="GA Release 2.4">
<action issue="LOG4J2-635" dev="rgoers" type="add">