Skip to content

Commit

Permalink
Merge pull request #208 from ryantenney/mdc-servlet-request-method
Browse files Browse the repository at this point in the history
Add request method to MDCInsertingServletFilter
  • Loading branch information
tony19 committed Dec 28, 2014
2 parents 3e699b9 + 7c818c0 commit 144dac9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Expand Up @@ -41,6 +41,7 @@ public class ClassicConstants {
public static final String REQUEST_REQUEST_URI = "req.requestURI";
public static final String REQUEST_QUERY_STRING = "req.queryString";
public static final String REQUEST_REQUEST_URL = "req.requestURL";
public static final String REQUEST_METHOD = "req.method";
public static final String REQUEST_X_FORWARDED_FOR = "req.xForwardedFor";

public static final String GAFFER_CONFIGURATOR_FQCN = "ch.qos.logback.classic.gaffer.GafferConfigurator";
Expand Down
Expand Up @@ -67,6 +67,7 @@ void insertIntoMDC(ServletRequest request) {
if (requestURL != null) {
MDC.put(ClassicConstants.REQUEST_REQUEST_URL, requestURL.toString());
}
MDC.put(ClassicConstants.REQUEST_METHOD, httpServletRequest.getMethod());
MDC.put(ClassicConstants.REQUEST_QUERY_STRING, httpServletRequest.getQueryString());
MDC.put(ClassicConstants.REQUEST_USER_AGENT_MDC_KEY, httpServletRequest
.getHeader("User-Agent"));
Expand All @@ -82,6 +83,7 @@ void clearMDC() {
MDC.remove(ClassicConstants.REQUEST_QUERY_STRING);
// removing possibly inexistent item is OK
MDC.remove(ClassicConstants.REQUEST_REQUEST_URL);
MDC.remove(ClassicConstants.REQUEST_METHOD);
MDC.remove(ClassicConstants.REQUEST_USER_AGENT_MDC_KEY);
MDC.remove(ClassicConstants.REQUEST_X_FORWARDED_FOR);
}
Expand Down
15 changes: 12 additions & 3 deletions logback-site/src/site/pages/manual/mdc.html
Expand Up @@ -674,6 +674,15 @@ <h3 class="doAnchor" name="mis">MDCInsertingServletFilter</h3>
</tr>

<tr class="alt">
<td><code>req.method</code></td>
<td>
as returned by <a
href="http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/http/HttpServletRequest.html#getMethod%28%29">getMethod()</a>
method
</td>
</tr>

<tr>
<td><code>req.requestURI</code></td>
<td>
as returned by <a
Expand All @@ -682,7 +691,7 @@ <h3 class="doAnchor" name="mis">MDCInsertingServletFilter</h3>
</td>
</tr>

<tr >
<tr class="alt">
<td><code>req.requestURL</code></td>
<td>
as returned by <a
Expand All @@ -691,15 +700,15 @@ <h3 class="doAnchor" name="mis">MDCInsertingServletFilter</h3>
</td>
</tr>

<tr class="alt">
<tr>
<td><code>req.queryString</code></td>
<td>
as returned by <a
href="http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/http/HttpServletRequest.html#getQueryString%28%29">getQueryString()</a> method
</td>
</tr>

<tr>
<tr class="alt">
<td><code>req.userAgent</code></td>
<td>value of the "User-Agent" header
</td>
Expand Down

0 comments on commit 144dac9

Please sign in to comment.