Tomcat 7:过滤器访问日志 [英] Tomcat 7: Filter access log
问题描述
我想知道是否有一种方法可以过滤/隐藏条目,使其免于登录到Tomcat 7的访问日志中.我们的日志文件越来越多,我们想知道是否可以过滤出条目,因此文件的增长速度不如现在.
I'd like to know if there is a way to filter/supress entries from getting logged in the access log in Tomcat 7. Our logfile is groing rapitly and we'd like to know if we can filter out entries so the file doesn't grow as fast as it is doing right now.
我们按照Tomcat配置文档中的描述使用访问日志阀.条目如下所示:
We use the Access Log Valve as described in the Tomcat configuration documentation. The entry looks like this:
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" resolveHosts="false" />
推荐答案
您可以使用"condition"属性根据请求属性过滤掉请求.
You can use "condition" attribute to filter out requests based on request attributes.
详细信息: http://tomcat.apache. org/tomcat-5.5-doc/config/valve.html#Access_Log_Valve/Attributes
您可以将"org.apache.catalina.valves.AccessLogValve"子类化以实现更具体的过滤器.
You can subclass "org.apache.catalina.valves.AccessLogValve" to implement more specific filter.
这篇关于Tomcat 7:过滤器访问日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!