<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
<Context path="/xxx" docBase="/data/www/xxx" reloadable="true" />
<Valve className="org.apache.catalina.valves.AccessLogValve" condition="drop" directory="/data/debug-logs/" rotatable="true" fileDateFormat="yyyy-MM-dd" pattern="%t %{sinternalid}s %{suserid}s %{x-up-calling-line-id}i" prefix="localhost_access_log." suffix=".log" />
</Host>
tomcat 格式化访问日志,而且可以从header、session中取值,很爽,节约大量的统计工作!
摘录官方网站一段:
There is also support to write information from the cookie, incoming header, the Session or something else in the ServletRequest. It is modeled after the apache syntax:
* %{xxx}i for incoming headers
* %{xxx}o for outgoing response headers
* %{xxx}c for a specific cookie
* %{xxx}r xxx is an attribute in the ServletRequest
* %{xxx}s xxx is an attribute in the HttpSession
官方文档页面:http://tomcat.apache.org/tomcat-6.0-doc/config/valve.html