Class RequestLoggingFilter

  • All Implemented Interfaces:
    javax.servlet.Filter

    public class RequestLoggingFilter
    extends Object
    implements javax.servlet.Filter
    Debugging filter: if configured, logs request and response of (preferably non-binary ;-) requests. Useful e.g. to get some examples for documentation.

    If the configuration is not present, it's inactive (configuration required). Thus it's easy to make this completely inactive on e.g. production servers.

    Since it is in some settings difficult to change configurations, this uses a special parameter "DebugRequestLoggingFilter-set-urlpattern" to change the logged url. https://somehost.somewhere.net/content/foo/bar/en.html?DebugRequestLoggingFilter-set-urlpattern=.*pdf.*

    • Field Detail

      • config

        protected com.composum.nodes.debugutil.RequestLoggingFilter.Config config
      • urlpattern

        protected volatile Pattern urlpattern
    • Constructor Detail

      • RequestLoggingFilter

        public RequestLoggingFilter()
    • Method Detail

      • doFilter

        public void doFilter​(javax.servlet.ServletRequest rawRequest,
                             javax.servlet.ServletResponse rawResponse,
                             javax.servlet.FilterChain chain)
                      throws IOException,
                             javax.servlet.ServletException
        Specified by:
        doFilter in interface javax.servlet.Filter
        Throws:
        IOException
        javax.servlet.ServletException
      • logRequestParametersAndHeaders

        protected void logRequestParametersAndHeaders​(org.apache.sling.api.SlingHttpServletRequest request)
      • activate

        public void activate​(com.composum.nodes.debugutil.RequestLoggingFilter.Config config)
      • setUrlPattern

        public void setUrlPattern​(String urlPattern)
      • deactivate

        public void deactivate()
      • init

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

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