Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Logback: the reliable, generic, fast and flexible logging framework. Copyright (C) 1999-2011, All rights reserved. This program and the accompanying materials are dual-licensed under either the terms of the Eclipse Public License v1.0 as published by the Eclipse Foundation or (per the licensee's choosing) under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation.
package ch.qos.logback.classic.helpers;
A servlet filter that inserts various values retrieved from the incoming http request into the MDC.

The values are removed after the request is processed.

Ceki Gülcü
public class MDCInsertingServletFilter implements Filter {
  public void destroy() {
    // do nothing
  public void doFilter(ServletRequest requestServletResponse response,
                       FilterChain chainthrows IOExceptionServletException {
    try {
    } finally {
  void insertIntoMDC(ServletRequest request) {
    if (request instanceof HttpServletRequest) {
      HttpServletRequest httpServletRequest = (HttpServletRequestrequest;
      StringBuffer requestURL = httpServletRequest.getRequestURL();
      if (requestURL != null) {
  void clearMDC() {
    // removing possibly inexistent item is OK
  public void init(FilterConfig arg0throws ServletException {
    // do nothing
New to GrepCode? Check out our FAQ X