Package com.composum.nodes.debugutil
Class RequestLoggingFilter
- java.lang.Object
-
- com.composum.nodes.debugutil.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.*
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
RequestLoggingFilter.LoggingReader
protected static class
RequestLoggingFilter.LoggingWriter
-
Field Summary
Fields Modifier and Type Field Description protected com.composum.nodes.debugutil.RequestLoggingFilter.Config
config
static String
PARAM_CONFIGURE_SERVLET
protected Pattern
urlpattern
-
Constructor Summary
Constructors Constructor Description RequestLoggingFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activate(com.composum.nodes.debugutil.RequestLoggingFilter.Config config)
void
deactivate()
void
destroy()
void
doFilter(javax.servlet.ServletRequest rawRequest, javax.servlet.ServletResponse rawResponse, javax.servlet.FilterChain chain)
void
init(javax.servlet.FilterConfig filterConfig)
protected void
logRequestParametersAndHeaders(org.apache.sling.api.SlingHttpServletRequest request)
void
setUrlPattern(String urlPattern)
-
-
-
Field Detail
-
config
protected com.composum.nodes.debugutil.RequestLoggingFilter.Config config
-
urlpattern
protected volatile Pattern urlpattern
-
PARAM_CONFIGURE_SERVLET
public static final String PARAM_CONFIGURE_SERVLET
- See Also:
- Constant Field Values
-
-
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 interfacejavax.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 interfacejavax.servlet.Filter
- Throws:
javax.servlet.ServletException
-
destroy
public void destroy()
- Specified by:
destroy
in interfacejavax.servlet.Filter
-
-