001/* 002 * Copyright 2002-2015 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.web.filter; 018 019import javax.servlet.http.HttpServletRequest; 020 021/** 022 * Simple request logging filter that writes the request URI 023 * (and optionally the query string) to the Commons Log. 024 * 025 * @author Rob Harrop 026 * @author Juergen Hoeller 027 * @since 1.2.5 028 * @see #setIncludeQueryString 029 * @see #setBeforeMessagePrefix 030 * @see #setBeforeMessageSuffix 031 * @see #setAfterMessagePrefix 032 * @see #setAfterMessageSuffix 033 * @see org.apache.commons.logging.Log#debug(Object) 034 */ 035public class CommonsRequestLoggingFilter extends AbstractRequestLoggingFilter { 036 037 @Override 038 protected boolean shouldLog(HttpServletRequest request) { 039 return logger.isDebugEnabled(); 040 } 041 042 /** 043 * Writes a log message before the request is processed. 044 */ 045 @Override 046 protected void beforeRequest(HttpServletRequest request, String message) { 047 logger.debug(message); 048 } 049 050 /** 051 * Writes a log message after the request is processed. 052 */ 053 @Override 054 protected void afterRequest(HttpServletRequest request, String message) { 055 logger.debug(message); 056 } 057 058}