看了一下tomcat的源码,你通过设置模式,可以达到目的。
<Valve className= "org.apache.catalina.valves.AccessLogValve "
directory= "logs " prefix= "localhost_access_log. " suffix= ".txt "
pattern= "%a %h %l %u %t %r %s %b " resolveHosts= "false "/>
下面是源码中摘录的参数的含义
* <li> <b> %a </b> - Remote IP address
* <li> <b> %A </b> - Local IP address
* <li> <b> %b </b> - Bytes sent, excluding HTTP headers, or '- ' if no bytes
* were sent
* <li> <b> %B </b> - Bytes sent, excluding HTTP headers
* <li> <b> %h </b> - Remote host name
* <li> <b> %H </b> - Request protocol
* <li> <b> %l </b> - Remote logical username from identd (always returns '- ')
* <li> <b> %m </b> - Request method
* <li> <b> %p </b> - Local port
* <li> <b> %q </b> - Query string (prepended with a '? ' if it exists, otherwise
* an empty string
* <li> <b> %r </b> - First line of the request
* <li> <b> %s </b> - HTTP status code of the response
* <li> <b> %S </b> - User session ID
* <li> <b> %t </b> - Date and time, in Common Log Format format
* <li> <b> %u </b> - Remote user that was authenticated
* <li> <b> %U </b> - Requested URL path
* <li> <b> %v </b> - Local server name
* <li> <b> %D </b> - Time taken to process the request, in millis
* <li> <b> %T </b> - Time taken to process the request, in seconds
<Valve className= "org.apache.catalina.valves.AccessLogValve "
directory= "logs " prefix= "localhost_access_log. " suffix= ".txt "
pattern= "%a %h %l %u %t %r %s %b " resolveHosts= "false "/>
下面是源码中摘录的参数的含义
* <li> <b> %a </b> - Remote IP address
* <li> <b> %A </b> - Local IP address
* <li> <b> %b </b> - Bytes sent, excluding HTTP headers, or '- ' if no bytes
* were sent
* <li> <b> %B </b> - Bytes sent, excluding HTTP headers
* <li> <b> %h </b> - Remote host name
* <li> <b> %H </b> - Request protocol
* <li> <b> %l </b> - Remote logical username from identd (always returns '- ')
* <li> <b> %m </b> - Request method
* <li> <b> %p </b> - Local port
* <li> <b> %q </b> - Query string (prepended with a '? ' if it exists, otherwise
* an empty string
* <li> <b> %r </b> - First line of the request
* <li> <b> %s </b> - HTTP status code of the response
* <li> <b> %S </b> - User session ID
* <li> <b> %t </b> - Date and time, in Common Log Format format
* <li> <b> %u </b> - Remote user that was authenticated
* <li> <b> %U </b> - Requested URL path
* <li> <b> %v </b> - Local server name
* <li> <b> %D </b> - Time taken to process the request, in millis
* <li> <b> %T </b> - Time taken to process the request, in seconds