棣栧厛鏄厤緗畉omcat璁塊棶鏃ュ織鏁版嵁錛岄粯璁ゆ儏鍐典笅璁塊棶鏃ュ織娌℃湁鎵撳紑錛岄厤緗殑鏂瑰紡濡備笅錛?br />
緙栬緫 ${catalina}/conf/server.xml鏂囦歡.娉?${catalina}鏄痶omcat鐨勫畨瑁呯洰褰?br />
鎶婁互涓嬬殑娉ㄩ噴(<!-- -->)鍘繪帀鍗沖彲銆?br />
<!--
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="localhost_access_log." suffix=".txt"
pattern="common" resolveHosts="false"/>
-->
鍏朵腑 directory鏄駭鐢熺殑鐩綍 tomcat瀹夎${catalina}浣滀負褰撳墠鐩綍
pattern琛ㄧず鏃ュ織鐢熶駭鐨勬牸寮忥紝common鏄痶omcat鎻愪緵鐨勪竴涓爣鍑嗚緗牸寮忋傚叾鍏蜂綋鐨勮〃杈懼紡涓?%h %l %u %t "%r" %s %b
浣嗘湰浜哄緩璁噰鐢ㄤ互涓嬪叿浣撶殑閰嶇疆錛屽洜涓烘爣鍑嗛厤緗湁涓浜涢噸瑕佺殑鏃ュ織鏁版嵁鏃犳硶鐢熴?br />
%h %l %u %t "%r" %s %b %T
鍏蜂綋鐨勬棩蹇椾駭鐢熸牱寮忚鏄庡涓?浠庡畼鏂規枃妗d腑鎽樺綍)錛?br />
* %a - Remote IP address
* %A - Local IP address
* %b - Bytes sent, excluding HTTP headers, or '-' if zero
* %B - Bytes sent, excluding HTTP headers
* %h - Remote host name (or IP address if resolveHosts is false)
* %H - Request protocol
* %l - Remote logical username from identd (always returns '-')
* %m - Request method (GET, POST, etc.)
* %p - Local port on which this request was received
* %q - Query string (prepended with a '?' if it exists)
* %r - First line of the request (method and request URI)
* %s - HTTP status code of the response
* %S - User session ID
* %t - Date and time, in Common Log Format
* %u - Remote user that was authenticated (if any), else '-'
* %U - Requested URL path
* %v - Local server name
* %D - Time taken to process the request, in millis
* %T - Time taken to process the request, in seconds
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}c for a specific cookie
* %{xxx}r xxx is an attribute in the ServletRequest
* %{xxx}s xxx is an attribute in the HttpSession