我正在使用CommonsRequestLoggingFilter
来记录传入请求的有效负载。但是对于一种方法,我不想记录有效载荷,因为它包含用户机密数据。我在web.xml
<filter>
<filter-name>LogFilter</filter-name>
<filter-class>org.springframework.web.filter.CommonsRequestLoggingFilter</filter-class>
<init-param>
<param-name>includePayload</param-name>
<param-value >true</param-value>
</init-param>
<init-param>
<param-name>includeQueryString</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>MaxPayloadLength</param-name>
<param-value>10000</param-value>
</init-param>
</filter>
帮我限制一种方法。
提前致谢
答案 0 :(得分:2)
您可以创建自己的扩展CommonsRequestLoggingFilter的类,并可以在该类中执行以下操作:-
@Override
protected String createMessage(HttpServletRequest request, String prefix, String suffix) {
//based on uri you could print payload or not.
}