Tomcat 7:过滤器访问日志 [英] Tomcat 7: Filter access log

查看:268
本文介绍了Tomcat 7:过滤器访问日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有一种方法可以过滤/隐藏条目,使其免于登录到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 &quot;%r&quot; %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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆