Class 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