You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2016/09/22 17:04:47 UTC
[1/2] logging-log4j2 git commit: [LOG4J2-1608] ServletAppender does
not provide throwable object to ServletContext.
Repository: logging-log4j2
Updated Branches:
refs/heads/master 800db9c7a -> 817d89838
[LOG4J2-1608] ServletAppender does not provide throwable object to
ServletContext.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/ed3c803f
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/ed3c803f
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/ed3c803f
Branch: refs/heads/master
Commit: ed3c803f3def3a9cc80908bbca8b3abe5ed19170
Parents: b4fb664
Author: Gary Gregory <gg...@apache.org>
Authored: Thu Sep 22 10:04:08 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Thu Sep 22 10:04:08 2016 -0700
----------------------------------------------------------------------
.../log4j/web/appender/ServletAppender.java | 2 +-
.../resources/WEB-INF/classes/log4j-servlet.xml | 64 ++++++++++----------
src/changes/changes.xml | 3 +
src/site/xdoc/manual/webapp.xml | 26 ++++++++
4 files changed, 62 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ed3c803f/log4j-web/src/main/java/org/apache/logging/log4j/web/appender/ServletAppender.java
----------------------------------------------------------------------
diff --git a/log4j-web/src/main/java/org/apache/logging/log4j/web/appender/ServletAppender.java b/log4j-web/src/main/java/org/apache/logging/log4j/web/appender/ServletAppender.java
index 6cfa74e..8bddc47 100644
--- a/log4j-web/src/main/java/org/apache/logging/log4j/web/appender/ServletAppender.java
+++ b/log4j-web/src/main/java/org/apache/logging/log4j/web/appender/ServletAppender.java
@@ -48,7 +48,7 @@ public class ServletAppender extends AbstractAppender {
@Override
public void append(final LogEvent event) {
- servletContext.log(((AbstractStringLayout) getLayout()).toSerializable(event));
+ servletContext.log(((AbstractStringLayout) getLayout()).toSerializable(event), event.getThrown());
}
/**
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ed3c803f/log4j-web/src/test/resources/WEB-INF/classes/log4j-servlet.xml
----------------------------------------------------------------------
diff --git a/log4j-web/src/test/resources/WEB-INF/classes/log4j-servlet.xml b/log4j-web/src/test/resources/WEB-INF/classes/log4j-servlet.xml
index b466c3d..017169c 100644
--- a/log4j-web/src/test/resources/WEB-INF/classes/log4j-servlet.xml
+++ b/log4j-web/src/test/resources/WEB-INF/classes/log4j-servlet.xml
@@ -1,33 +1,33 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
-
--->
-<Configuration status="WARN" name="ServletTest">
-
- <Appenders>
- <Servlet name="Servlet">
- <PatternLayout pattern="%m%n"/>
- </Servlet>
- </Appenders>
-
- <Loggers>
- <Root level="debug">
- <AppenderRef ref="Servlet"/>
- </Root>
- </Loggers>
-
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+
+-->
+<Configuration status="WARN" name="ServletTest">
+
+ <Appenders>
+ <Servlet name="Servlet">
+ <PatternLayout pattern="%m%n%ex{none}"/>
+ </Servlet>
+ </Appenders>
+
+ <Loggers>
+ <Root level="debug">
+ <AppenderRef ref="Servlet"/>
+ </Root>
+ </Loggers>
+
</Configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ed3c803f/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 036e633..7e69b6d 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -156,6 +156,9 @@
<action issue="LOG4J2-1573" dev="ggregory" type="fix" due-to="Steffen Offermann">
Layout is no longer optional.
</action>
+ <action issue="LOG4J2-1608" dev="ggregory" type="fix">
+ ServletAppender does not provide throwable object to ServletContext.
+ </action>
<action issue="LOG4J2-1599" dev="ggregory" type="fix">
Prevent potential NPE in org.apache.logging.log4j.message.ParameterFormatter.formatMessage3(StringBuilder, char[], int, Object[], int, int[]).
</action>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ed3c803f/src/site/xdoc/manual/webapp.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/manual/webapp.xml b/src/site/xdoc/manual/webapp.xml
index 57fea45..ade3236 100644
--- a/src/site/xdoc/manual/webapp.xml
+++ b/src/site/xdoc/manual/webapp.xml
@@ -419,6 +419,32 @@ public class TestAsyncServlet extends HttpServlet {
context in a <code>finally</code> block, which will always execute.
</p>
</subsection>
+ <subsection name="Using the Servlet Appender">
+ <p>
+ Log4j provides a Servlet Appender that uses the servlet context as the log target. For example:
+ </p>
+ <pre class="prettyprint linenums"><![CDATA[
+<Configuration status="WARN" name="ServletTest">
+
+ <Appenders>
+ <Servlet name="Servlet">
+ <PatternLayout pattern="%m%n%ex{none}"/>
+ </Servlet>
+ </Appenders>
+
+ <Loggers>
+ <Root level="debug">
+ <AppenderRef ref="Servlet"/>
+ </Root>
+ </Loggers>
+
+</Configuration>]]></pre>
+ <p>
+ To avoid double logging of exceptions to the servlet context, you must use <code>%ex{none}</code> in your
+ <code>PatternLayout</code> as shown in the example. The exception will be omitted from the message text but
+ it is passed to the servlet context as the actual Throwable object.
+ </p>
+ </subsection>
</section>
</body>
[2/2] logging-log4j2 git commit: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/logging-log4j2.git
Posted by gg...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/logging-log4j2.git
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/817d8983
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/817d8983
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/817d8983
Branch: refs/heads/master
Commit: 817d89838afea77e35048cbc8da7a5df38a0076a
Parents: ed3c803 800db9c
Author: Gary Gregory <gg...@apache.org>
Authored: Thu Sep 22 10:04:30 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Thu Sep 22 10:04:30 2016 -0700
----------------------------------------------------------------------
.../CopyOnWriteSortedArrayThreadContextMap.java | 66 +-
.../log4j/spi/DefaultThreadContextMap.java | 4 +-
.../GarbageFreeSortedArrayThreadContextMap.java | 66 +-
.../logging/log4j/spi/ThreadContextMap2.java | 8 +-
.../apache/logging/log4j/util/BiConsumer.java | 2 +-
.../apache/logging/log4j/util/ContextData.java | 106 ---
.../logging/log4j/util/MutableContextData.java | 98 ---
.../logging/log4j/util/ReadOnlyStringMap.java | 106 +++
.../log4j/util/SortedArrayStringMap.java | 477 ++++++++++++
.../log4j/util/SortedStringArrayMap.java | 477 ------------
.../apache/logging/log4j/util/StringMap.java | 98 +++
.../apache/logging/log4j/util/TriConsumer.java | 2 +-
.../log4j/util/SortedArrayStringMapTest.java | 772 +++++++++++++++++++
.../log4j/util/SortedStringArrayMapTest.java | 772 -------------------
.../logging/log4j/core/AbstractLogEvent.java | 4 +-
.../logging/log4j/core/ContextDataInjector.java | 30 +-
.../org/apache/logging/log4j/core/LogEvent.java | 8 +-
.../db/jpa/AbstractLogEventWrapperEntity.java | 8 +-
.../ContextDataAttributeConverter.java | 10 +-
.../ContextDataJsonAttributeConverter.java | 14 +-
.../logging/log4j/core/async/AsyncLogger.java | 8 +-
.../log4j/core/async/RingBufferLogEvent.java | 12 +-
.../async/RingBufferLogEventTranslator.java | 4 +-
.../core/filter/DynamicThresholdFilter.java | 6 +-
.../logging/log4j/core/filter/MapFilter.java | 4 +-
.../core/filter/ThreadContextMapFilter.java | 6 +-
.../log4j/core/impl/ContextDataFactory.java | 24 +-
.../core/impl/ContextDataInjectorFactory.java | 6 +-
.../logging/log4j/core/impl/Log4jLogEvent.java | 38 +-
.../log4j/core/impl/MutableLogEvent.java | 12 +-
.../core/impl/ReusableLogEventFactory.java | 4 +-
.../core/impl/ThreadContextDataInjector.java | 80 +-
.../ContextDataAsEntryListDeserializer.java | 8 +-
.../ContextDataAsEntryListSerializer.java | 6 +-
.../core/jackson/ContextDataDeserializer.java | 8 +-
.../core/jackson/ContextDataSerializer.java | 6 +-
.../log4j/core/jackson/LogEventJsonMixIn.java | 4 +-
.../jackson/LogEventWithContextListMixIn.java | 4 +-
.../log4j/core/lookup/ContextMapLookup.java | 4 +-
.../log4j/core/pattern/MdcPatternConverter.java | 8 +-
.../core/appender/db/jpa/TestBaseEntity.java | 4 +-
.../ContextDataAttributeConverterTest.java | 8 +-
.../ContextDataJsonAttributeConverterTest.java | 14 +-
.../core/async/RingBufferLogEventTest.java | 16 +-
.../log4j/core/impl/Log4jLogEventTest.java | 8 +-
.../log4j/core/impl/MutableLogEventTest.java | 10 +-
.../log4j/flume/appender/FlumeEvent.java | 4 +-
.../perf/jmh/SortedArrayVsHashMapBenchmark.java | 18 +-
.../log4j/perf/jmh/ThreadContextBenchmark.java | 12 +-
.../log4j/perf/nogc/OpenHashMapContextData.java | 24 +-
.../CopyOnWriteOpenHashMapThreadContextMap.java | 8 +-
.../GarbageFreeOpenHashMapThreadContextMap.java | 8 +-
.../org/apache/logging/slf4j/MDCContextMap.java | 10 +-
53 files changed, 1762 insertions(+), 1762 deletions(-)
----------------------------------------------------------------------