Class AccessLogFilter
- All Implemented Interfaces:
Filter
For each servlet request, this filter logs:
- the request HTTP method,
- the request URI (including its query parameters),
- the request HTTP protocol,
- the response HTTP status,
- the execution time to produce the response,
- the request headers (see below for header configuration),
- the response headers (see below for header configuration)
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 HTTP/1.1 200 541ms
The logging level used must be DEBUG or TRACE. Logging is activated either by setting the root level to DEBUG/TRACE or specifically for this class.
In DEBUG level, by default, this filter logs only the request and response headers defined by the Options.OPTION_ACCESS_LOG_HEADERS option.
This can be overridden by a system property of the same name as follows:
-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 HTTP/1.1 200 541ms
Important Request HTTP Headers:
Accept: text/html
Important Response HTTP Headers:
Content-Type: text/html;charset=UTF-8
Alternatively, and with the highest precedence, a context parameter with the same name can be used for customization. Header names are comma-separated in this parameter and also for the system property.
In TRACE level, this filter logs ALL request and response headers by default (ignoring the oslc.accessLog.headers setting above).
By default, this filter masks the request and response headers defined by the Options.OPTION_ACCESS_LOG_MASKED_HEADERS option.
The same mechanisms to overridde the Options.OPTION_ACCESS_LOG_HEADERS option applies to this one: system property and context parameter.
- Since:
- 1.4.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoFilter(HttpServletRequest req, HttpServletResponse res, FilterChain chain) Processes this filter and either executes or blocks the chain.voidinit(FilterConfig config) This implementation does nothing.Methods inherited from class com.sodius.oslc.server.services.HttpFilter
destroy, doFilter, handleOslcError
-
Constructor Details
-
AccessLogFilter
public AccessLogFilter()
-
-
Method Details
-
init
Description copied from class:HttpFilterThis implementation does nothing. Subclasses may override.- Specified by:
initin interfaceFilter- Overrides:
initin classHttpFilter- Parameters:
config- the configuration of the filter.- Throws:
ServletException- not thrown by this implementation.
-
doFilter
protected void doFilter(HttpServletRequest req, HttpServletResponse res, FilterChain chain) throws IOException, ServletException Description copied from class:HttpFilterProcesses this filter and either executes or blocks the chain.Subclasses may throw a
OslcWebApplicationExceptionto report anOslcError. This filter will automatically serialize such error in the HTTP response.- Specified by:
doFilterin classHttpFilter- Parameters:
req- the request.res- the response.chain- the filter chain to process.- Throws:
IOException- if an I/O error occurs.ServletException- if the filter execution fails.
-