1 16 17 package org.springframework.web.filter; 18 19 import javax.servlet.http.HttpServletRequest ; 20 21 import org.apache.log4j.Logger; 22 import org.apache.log4j.NDC; 23 24 40 public class Log4jNestedDiagnosticContextFilter extends AbstractRequestLoggingFilter { 41 42 43 protected final Logger log4jLogger = Logger.getLogger(getClass()); 44 45 46 50 protected void beforeRequest(HttpServletRequest request, String message) { 51 if (log4jLogger.isDebugEnabled()) { 52 log4jLogger.debug(message); 53 } 54 NDC.push(getNestedDiagnosticContextMessage(request)); 55 } 56 57 64 protected String getNestedDiagnosticContextMessage(HttpServletRequest request) { 65 return createMessage(request, "", ""); 66 } 67 68 72 protected void afterRequest(HttpServletRequest request, String message) { 73 NDC.pop(); 74 if (log4jLogger.isDebugEnabled()) { 75 log4jLogger.debug(message); 76 } 77 } 78 79 } 80 | Popular Tags |