[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, master, updated. v0.9.18-97-g544292b
added by portage for gitosis-gentoo
git-noreply at pixie.qos.ch
Fri Mar 19 13:48:28 CET 2010
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".
The branch, master has been updated
via 544292b758f9d296f581b6ec265fbeea954e6c6a (commit)
from ea6065ca315b78c7e0eb40d3fe85faec6441a834 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=544292b758f9d296f581b6ec265fbeea954e6c6a
http://github.com/ceki/logback/commit/544292b758f9d296f581b6ec265fbeea954e6c6a
commit 544292b758f9d296f581b6ec265fbeea954e6c6a
Author: Ceki Gulcu <ceki at qos.ch>
Date: Fri Mar 19 13:46:55 2010 +0100
- added req.requestURL to MDCInsertingServletFilter
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/ClassicConstants.java b/logback-classic/src/main/java/ch/qos/logback/classic/ClassicConstants.java
index 492c8e4..12fedc5 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/ClassicConstants.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/ClassicConstants.java
@@ -35,7 +35,8 @@ public class ClassicConstants {
public final static String REQUEST_REMOTE_HOST_MDC_KEY = "req.remoteHost";
public final static String REQUEST_USER_AGENT_MDC_KEY = "req.userAgent";
- public final static String REQUEST_REQUST_URI = "req.requestURI";
+ public final static String REQUEST_REQUEST_URI = "req.requestURI";
+ public final static String REQUEST_REQUEST_URL = "req.requestURL";
public final static String REQUEST_X_FORWARDED_FOR = "req.xForwardedFor";
}
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/helpers/MDCInsertingServletFilter.java b/logback-classic/src/main/java/ch/qos/logback/classic/helpers/MDCInsertingServletFilter.java
index d9f25d6..5efae36 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/helpers/MDCInsertingServletFilter.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/helpers/MDCInsertingServletFilter.java
@@ -31,8 +31,9 @@ import ch.qos.logback.classic.ClassicConstants;
* A servlet filter that inserts various values retrieved from the incoming http
* request into the MDC.
*
- * <p>The values are removed after the request is processed.
- *
+ * <p>
+ * The values are removed after the request is processed.
+ *
* @author Ceki Gülcü
*/
public class MDCInsertingServletFilter implements Filter {
@@ -57,11 +58,15 @@ public class MDCInsertingServletFilter implements Filter {
MDC.put(ClassicConstants.REQUEST_REMOTE_HOST_MDC_KEY, request
.getRemoteHost());
-
+
if (request instanceof HttpServletRequest) {
HttpServletRequest httpServletRequest = (HttpServletRequest) request;
- MDC.put(ClassicConstants.REQUEST_REQUST_URI, httpServletRequest
+ MDC.put(ClassicConstants.REQUEST_REQUEST_URI, httpServletRequest
.getRequestURI());
+ StringBuffer requestURL = httpServletRequest.getRequestURL();
+ if (requestURL != null) {
+ MDC.put(ClassicConstants.REQUEST_REQUEST_URL, requestURL.toString());
+ }
MDC.put(ClassicConstants.REQUEST_USER_AGENT_MDC_KEY, httpServletRequest
.getHeader("User-Agent"));
MDC.put(ClassicConstants.REQUEST_X_FORWARDED_FOR, httpServletRequest
@@ -72,8 +77,11 @@ public class MDCInsertingServletFilter implements Filter {
void clearMDC() {
MDC.remove(ClassicConstants.REQUEST_REMOTE_HOST_MDC_KEY);
- MDC.remove(ClassicConstants.REQUEST_REQUST_URI);
+ MDC.remove(ClassicConstants.REQUEST_REQUEST_URI);
+ // removing possibly inexistent item is OK
+ MDC.remove(ClassicConstants.REQUEST_REQUEST_URL);
MDC.remove(ClassicConstants.REQUEST_USER_AGENT_MDC_KEY);
+ MDC.remove(ClassicConstants.REQUEST_X_FORWARDED_FOR);
}
public void init(FilterConfig arg0) throws ServletException {
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/util/LogbackMDCAdapter.java b/logback-classic/src/main/java/ch/qos/logback/classic/util/LogbackMDCAdapter.java
index 9af2532..2c4f807 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/util/LogbackMDCAdapter.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/util/LogbackMDCAdapter.java
@@ -19,14 +19,16 @@ import java.util.Set;
import org.slf4j.spi.MDCAdapter;
-
/**
- * A <em>Mapped Diagnostic Context</em>, or MDC in short, is an instrument
- * for distinguishing interleaved log output from different sources. Log output
- * is typically interleaved when a server handles multiple clients
- * near-simultaneously. <p> <b><em>The MDC is managed on a per thread basis</em></b>.
- * A child thread automatically inherits a <em>copy</em> of the mapped
- * diagnostic context of its parent. <p>
+ * A <em>Mapped Diagnostic Context</em>, or MDC in short, is an instrument for
+ * distinguishing interleaved log output from different sources. Log output is
+ * typically interleaved when a server handles multiple clients
+ * near-simultaneously.
+ * <p>
+ * <b><em>The MDC is managed on a per thread basis</em></b>. A child thread
+ * automatically inherits a <em>copy</em> of the mapped diagnostic context of
+ * its parent.
+ * <p>
*
* For more information about MDC, please refer to the online manual at
* http://logback.qos.ch/manual/mdc.html
@@ -44,20 +46,22 @@ public class LogbackMDCAdapter implements MDCAdapter {
}
/**
- * Put a context value (the <code>val</code> parameter) as identified with
- * the <code>key</code> parameter into the current thread's context map.
- * Note that contrary to log4j, the <code>val</code> parameter can be null.
+ * Put a context value (the <code>val</code> parameter) as identified with the
+ * <code>key</code> parameter into the current thread's context map. Note that
+ * contrary to log4j, the <code>val</code> parameter can be null.
*
- * <p> If the current thread does not have a context map it is created as a
- * side effect of this call.
+ * <p>
+ * If the current thread does not have a context map it is created as a side
+ * effect of this call.
*
- * <p> Each time a value is added, a new instance of the map is created. This
- * is to be certain that the serialization process will operate on the updated
+ * <p>
+ * Each time a value is added, a new instance of the map is created. This is
+ * to be certain that the serialization process will operate on the updated
* map and not send a reference to the old map, thus not allowing the remote
* logback component to see the latest changes.
*
* @throws IllegalArgumentException
- * in case the "key" parameter is null
+ * in case the "key" parameter is null
*/
public void put(String key, String val) throws IllegalArgumentException {
if (key == null) {
@@ -78,7 +82,8 @@ public class LogbackMDCAdapter implements MDCAdapter {
/**
* Get the context identified by the <code>key</code> parameter.
*
- * <p> This method has no side effects.
+ * <p>
+ * This method has no side effects.
*/
public String get(String key) {
HashMap<String, String> hashMap = copyOnInheritThreadLocal.get();
@@ -93,12 +98,16 @@ public class LogbackMDCAdapter implements MDCAdapter {
/**
* Remove the the context identified by the <code>key</code> parameter.
*
- * <p> Each time a value is removed, a new instance of the map is created.
- * This is to be certain that the serialization process will operate on the
- * updated map and not send a reference to the old map, thus not allowing the
- * remote logback component to see the latest changes.
+ * <p>
+ * Each time a value is removed, a new instance of the map is created. This is
+ * to be certain that the serialization process will operate on the updated
+ * map and not send a reference to the old map, thus not allowing the remote
+ * logback component to see the latest changes.
*/
public void remove(String key) {
+ if(key == null) {
+ return;
+ }
HashMap<String, String> oldMap = copyOnInheritThreadLocal.get();
HashMap<String, String> newMap = new HashMap<String, String>();
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/util/LogbackMDCAdapterTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/util/LogbackMDCAdapterTest.java
index 24dc122..a88d9d0 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/util/LogbackMDCAdapterTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/util/LogbackMDCAdapterTest.java
@@ -51,6 +51,18 @@ public class LogbackMDCAdapterTest {
assertNull(childThread.childHM);
}
+ @Test
+ public void removeForNullKey() {
+ LogbackMDCAdapter lma = new LogbackMDCAdapter();
+ lma.remove(null);
+ }
+
+ @Test
+ public void removeInexistnetKey() {
+ LogbackMDCAdapter lma = new LogbackMDCAdapter();
+ lma.remove("abcdlw0");
+ }
+
class ChildThreadForMDCAdapter extends Thread {
LogbackMDCAdapter logbackMDCAdapter;
diff --git a/logback-site/src/site/pages/index.html b/logback-site/src/site/pages/index.html
index f9942ce..0cd8ee0 100644
--- a/logback-site/src/site/pages/index.html
+++ b/logback-site/src/site/pages/index.html
@@ -56,14 +56,21 @@
</p>
- <h3>Select projects known to rely on logback</h3>
+ <h3>Projects known to rely on logback</h3>
- <ul>
+ <p>Here is a non-exhaustive list of projects known to depend on
+ logback, in alphabetical order:
+ </p>
+
+ <ul>
<li><a href="http://www.jfrog.org/products.php">Artifactory</a></li>
<li><a href="http://www.geomajas.org/">Geomajas</a></li>
+ <li><a href="http://jmxmonitor.sourceforge.net/">jmxmonitor</a></li>
+
+
<li><a href="http://code.google.com/p/openmeetings/">OpenMeetings</a></li>
<li><a href="http://liftweb.net/">Lift</a></li>
diff --git a/logback-site/src/site/pages/manual/mdc.html b/logback-site/src/site/pages/manual/mdc.html
index 6cdfc59..9cf843b 100644
--- a/logback-site/src/site/pages/manual/mdc.html
+++ b/logback-site/src/site/pages/manual/mdc.html
@@ -678,6 +678,15 @@ public class UserServletFilter implements Filter {
</tr>
<tr >
+ <td><code>req.requestURL</code></td>
+ <td>
+ as returned by <a
+ href="http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/http/HttpServletRequest.html#getRequestURL%28%29">getRequestURL()</a>
+ method
+ </td>
+ </tr>
+
+ <tr class="alt">
<td><code>req.userAgent</code></td>
<td>value of the "User-Agent" header
</td>
-----------------------------------------------------------------------
Summary of changes:
.../ch/qos/logback/classic/ClassicConstants.java | 3 +-
.../classic/helpers/MDCInsertingServletFilter.java | 18 +++++--
.../logback/classic/util/LogbackMDCAdapter.java | 49 ++++++++++++--------
.../classic/util/LogbackMDCAdapterTest.java | 12 +++++
logback-site/src/site/pages/index.html | 11 ++++-
logback-site/src/site/pages/manual/mdc.html | 9 ++++
6 files changed, 74 insertions(+), 28 deletions(-)
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
More information about the logback-dev
mailing list