public abstract class AbstractQueryCountLoggingServletFilter extends Object implements javax.servlet.Filter
By default, the filter resets the QueryCountHolder after logging the query count, so
each HTTP request starts with a fresh set of query statistics. To control when the counter is reset, disable
automatic clearing by setting the clearQueryCounter filter parameter to false.
loggerName parameter (optional): creates a logger with the specified name.
<filter>
<filter-name>count</filter-name>
<filter-class>net.ttddyy.dsproxy.support.CommonsQueryCountLoggingFilter</filter-class>
<init-param>
<param-name>logLevel</param-name>
<param-value>INFO</param-value>
<init-param>
<init-param>
<param-name>clearQueryCounter</param-name>
<param-value>false</param-value>
<init-param>
<init-param>
<param-name>loggerName</param-name>
<param-value>myLogger</param-value>
<init-param>
</filter>
CommonsQueryCountLoggingServletFilter,
SLF4JQueryCountLoggingServletFilter| Modifier and Type | Field and Description |
|---|---|
static String |
CLEAR_QUERY_COUNTER_PARAM |
protected boolean |
clearQueryCounter |
static String |
FORMAT_PARAM |
static String |
LOG_LEVEL_PARAM |
protected QueryCountLogEntryCreator |
logFormatter |
static String |
LOGGER_NAME |
protected boolean |
writeAsJson |
| Constructor and Description |
|---|
AbstractQueryCountLoggingServletFilter() |
| Modifier and Type | Method and Description |
|---|---|
void |
destroy() |
void |
doFilter(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response,
javax.servlet.FilterChain chain) |
void |
init(javax.servlet.FilterConfig filterConfig) |
protected abstract void |
initLogLevelFromFilterConfigIfSpecified(String logLevelParam) |
protected abstract void |
resetLogger(String loggerName)
Callback method to reset the logger object in concrete class when log name is specified.
|
void |
setClearQueryCounter(boolean clearQueryCounter) |
void |
setLogFormatter(QueryCountLogEntryCreator logFormatter) |
void |
setWriteAsJson(boolean writeAsJson) |
protected abstract void |
writeLog(String message) |
public static final String CLEAR_QUERY_COUNTER_PARAM
public static final String LOG_LEVEL_PARAM
public static final String FORMAT_PARAM
public static final String LOGGER_NAME
protected boolean clearQueryCounter
protected boolean writeAsJson
protected QueryCountLogEntryCreator logFormatter
public AbstractQueryCountLoggingServletFilter()
public void init(javax.servlet.FilterConfig filterConfig)
throws javax.servlet.ServletException
init in interface javax.servlet.Filterjavax.servlet.ServletExceptionpublic void doFilter(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response,
javax.servlet.FilterChain chain)
throws IOException,
javax.servlet.ServletException
doFilter in interface javax.servlet.FilterIOExceptionjavax.servlet.ServletExceptionpublic void destroy()
destroy in interface javax.servlet.Filterprotected abstract void initLogLevelFromFilterConfigIfSpecified(String logLevelParam)
protected abstract void writeLog(String message)
protected abstract void resetLogger(String loggerName)
loggerName - logger namepublic void setClearQueryCounter(boolean clearQueryCounter)
public void setLogFormatter(QueryCountLogEntryCreator logFormatter)
public void setWriteAsJson(boolean writeAsJson)
Copyright © 2026. All rights reserved.