Class AccessLogFilter
- java.lang.Object
-
- com.sodius.oslc.server.services.HttpFilter
-
- com.sodius.oslc.server.services.AccessLogFilter
-
- All Implemented Interfaces:
Filter
public class AccessLogFilter extends HttpFilter
Logs all servlet requests and their responses.For each servlet request, this filter logs:
- the request URI (including its query parameters),
- the request headers (see below for header configuration),
- the response HTTP status,
- the response headers (see below for header configuration),
- the execution time to produce the response
A logged request looks like the following:
2018-12-10 10:20:37,112 [qtp252455605-43] DEBUG com.sodius.oslc.server.services.AccessLogFilter - "GET /app/web/index.html" 200 541
The logging level used is DEBUG. Logging is activated either by setting the root level to DEBUG or specifically for this class using following Log4J configuration:
log4j.logger.com.sodius.oslc.server.services.AccessLogFilter = DEBUG
This filter does not log any request nor response header by default. A
"oslc.accessLog.headers"
context parameter can be used to indicate the request and response headers to log. Header names are comma-separated in this parameter. The context parameter can be set using a Java system property:-Doslc.accessLog.headers=Accept,Content-Type
which logs the following:
2018-12-10 10:20:37,112 [qtp252455605-43] DEBUG com.sodius.oslc.server.services.AccessLogFilter - "GET /app/web/index.html" [Accept="text/html"] HTTP 200 [Content-Type="text/html;charset=UTF-8"] 541ms
- Since:
- 1.4.0
-
-
Constructor Summary
Constructors Constructor Description AccessLogFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
Processes this filter and either executes or blocks the chain.void
init(FilterConfig config)
This implementation does nothing.-
Methods inherited from class com.sodius.oslc.server.services.HttpFilter
destroy, doFilter, handleOslcError
-
-
-
-
Method Detail
-
init
public void init(FilterConfig config) throws ServletException
Description copied from class:HttpFilter
This implementation does nothing. Subclasses may override.- Specified by:
init
in interfaceFilter
- Overrides:
init
in classHttpFilter
- Parameters:
config
- the configuration of the filter.- Throws:
ServletException
- not thrown by this implementation.
-
doFilter
protected void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException
Description copied from class:HttpFilter
Processes this filter and either executes or blocks the chain.Subclasses may throw a
OslcWebApplicationException
to report anOslcError
. This filter will automatically serialize such error in the HTTP response.- Specified by:
doFilter
in classHttpFilter
- Parameters:
request
- the request.response
- the response.chain
- the filter chain to process.- Throws:
IOException
- if an I/O error occurs.ServletException
- if the filter execution fails.
-
-