public class RequestResponseLoggingFilter extends Object implements javax.servlet.Filter
addSupportedContentTypes(String...)
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_REQUEST_MESSAGE_PREFIX |
static String |
DEFAULT_REQUEST_MESSAGE_SUFFIX |
static String |
DEFAULT_RESPONSE_MESSAGE_PREFIX |
static String |
DEFAULT_RESPONSE_MESSAGE_SUFFIX |
Constructor and Description |
---|
RequestResponseLoggingFilter() |
Modifier and Type | Method and Description |
---|---|
void |
addSupportedContentTypes(String... contentTypes)
Adds content types which should be logged.
|
void |
destroy() |
void |
doFilter(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response,
javax.servlet.FilterChain chain) |
protected int |
getMaxResponsePayloadLength()
Return the maximum length of the payload body to be included in the log message.
|
protected int |
getRequestMaxPayloadLength()
Return the maximum length of the request payload body to be included in the log message.
|
protected String |
getRequestMessage(javax.servlet.http.HttpServletRequest request)
Get the message to write to the log the request.
|
protected String |
getResponseMessage(javax.servlet.ServletResponse response,
byte[] copy)
Get the message to write to the log the response.
|
protected List<String> |
getSupportedContentTypes()
Returns the actually supported content types of request which should be logged.
|
void |
init(javax.servlet.FilterConfig filterConf) |
protected boolean |
isIncludeClientInfo()
Return whether the client address and session id should be included in the
log message.
|
protected boolean |
isLogUnsupportedContentType()
Return whether the unsupported content type should be included in the
log message.
|
void |
setIncludeClientInfo(boolean includeClientInfo)
Set whether the client address and session id should be included in the
log message.
|
void |
setLogUnsupportedContentType(boolean logUnsupportedContentType)
Set whether the unsupported content types should be logged or not.
|
void |
setMaxRequestPayloadLength(int maxRequestPayloadLength)
Sets the maximum length of the request payload body to be included in the log message.
|
void |
setMaxResponsePayloadLength(int maxResponsePayloadLength)
Sets the maximum length of the response payload body to be included in the log message.
|
void |
setRequestMessagePrefix(String beforeMessagePrefix)
Set the value that should be prepended to the log message written
before a request is processed.
|
void |
setRequestMessageSuffix(String beforeMessageSuffix)
Set the value that should be appended to the log message written
before a request is processed.
|
void |
setResponseMessagePrefix(String afterMessagePrefix)
Set the value that should be prepended to the log message written
after a request is processed.
|
void |
setResponseMessageSuffix(String afterMessageSuffix)
Set the value that should be appended to the log message written
after a request is processed.
|
public static final String DEFAULT_REQUEST_MESSAGE_PREFIX
public static final String DEFAULT_REQUEST_MESSAGE_SUFFIX
public static final String DEFAULT_RESPONSE_MESSAGE_PREFIX
public static final String DEFAULT_RESPONSE_MESSAGE_SUFFIX
public void init(javax.servlet.FilterConfig filterConf) throws javax.servlet.ServletException
init
in interface javax.servlet.Filter
javax.servlet.ServletException
public void destroy()
destroy
in interface javax.servlet.Filter
public void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain) throws IOException, javax.servlet.ServletException
doFilter
in interface javax.servlet.Filter
IOException
javax.servlet.ServletException
public void setRequestMessagePrefix(String beforeMessagePrefix)
public void setRequestMessageSuffix(String beforeMessageSuffix)
public void setResponseMessagePrefix(String afterMessagePrefix)
public void setResponseMessageSuffix(String afterMessageSuffix)
public void setIncludeClientInfo(boolean includeClientInfo)
Should be configured using an <init-param>
for parameter name
"includeClientInfo" in the filter definition in web.xml
.
protected boolean isIncludeClientInfo()
public void setMaxRequestPayloadLength(int maxRequestPayloadLength)
DEFAULT_MAX_REQUEST_PAYLOAD_LENGTH
protected int getRequestMaxPayloadLength()
public void setMaxResponsePayloadLength(int maxResponsePayloadLength)
DEFAULT_MAX_RESPONSE_PAYLOAD_LENGTH
protected int getMaxResponsePayloadLength()
protected List<String> getSupportedContentTypes()
public void addSupportedContentTypes(String... contentTypes)
contentTypes
- as collection of supported content typespublic void setLogUnsupportedContentType(boolean logUnsupportedContentType)
protected boolean isLogUnsupportedContentType()
protected String getRequestMessage(javax.servlet.http.HttpServletRequest request)
protected String getResponseMessage(javax.servlet.ServletResponse response, byte[] copy)
Copyright © 2018 Pivotal Software, Inc.. All rights reserved.