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 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