Tomcat 7: Filter access log

2019-07-07 18:56发布

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.

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" />

1条回答
聊天终结者
2楼-- · 2019-07-07 19:39

You can use "condition" attribute to filter out requests based on request attributes.

Details : http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html#Access_Log_Valve/Attributes

You can subclass "org.apache.catalina.valves.AccessLogValve" to implement more specific filter.

查看更多
登录 后发表回答