nl.surfnet.coin.shared.filter
Class LoggingFilter

java.lang.Object
  extended by nl.surfnet.coin.shared.filter.LoggingFilter
All Implemented Interfaces:
javax.servlet.Filter

public class LoggingFilter
extends Object
implements javax.servlet.Filter

Filter that grabs relevant request and response data and log it using the regular logger. Two logging categories are defined and used, not named after the class but 'request' and 'response'. At DEBUG level, the complete request URL, including query string, is logged, together with the response's status line. At TRACE level, the request headers, and the complete response body are logged as well. For correlation of request/response, a unique request ID is generated per request and is logged.


Nested Class Summary
static class LoggingFilter.MemorizingResponseWrapper
          Response wrapper that keeps the response for logging, as well as the HTTP status.
 
Field Summary
static String OUTPUT_STREAM_COPY_ATTR
           
static String REQUEST_ID_ATTR
           
 
Constructor Summary
LoggingFilter()
           
 
Method Summary
 void destroy()
           
 void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)
           
protected  String generateRequestId()
          Create a request id.
 void init(javax.servlet.FilterConfig filterConfig)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REQUEST_ID_ATTR

public static final String REQUEST_ID_ATTR
See Also:
Constant Field Values

OUTPUT_STREAM_COPY_ATTR

public static final String OUTPUT_STREAM_COPY_ATTR
See Also:
Constant Field Values
Constructor Detail

LoggingFilter

public LoggingFilter()
Method Detail

init

public void init(javax.servlet.FilterConfig filterConfig)
          throws javax.servlet.ServletException
Specified by:
init in interface javax.servlet.Filter
Throws:
javax.servlet.ServletException

doFilter

public void doFilter(javax.servlet.ServletRequest request,
                     javax.servlet.ServletResponse response,
                     javax.servlet.FilterChain chain)
              throws IOException,
                     javax.servlet.ServletException
Specified by:
doFilter in interface javax.servlet.Filter
Throws:
IOException
javax.servlet.ServletException

generateRequestId

protected String generateRequestId()
Create a request id. Calls to it are synchronized externally, so the implementation does not have to be thread safe.

Returns:
unique string

destroy

public void destroy()
Specified by:
destroy in interface javax.servlet.Filter


Copyright © 2009–2013 SURFnet bv, The Netherlands. All rights reserved.