Configure access log in Tomcat to monitor the processing time of each HTTP Request

Source: Internet
Author: User

Tomcat 6 configuration official documentation: http://tomcat.apache.org/tomcat-6.0-doc/config/valve.html

 

Configure the <value/> element in CONF/server. xml. You can configure the <value/> element under (context, host, or engine) and other elements.

<Valveclassname = "org. Apache. Catalina. Valves. accesslogvalve"

Directory = "logs" prefix = "access_log." suffix = ". ACC" rotatable = "true" filedateformat = "yyyy-mm-dd"

Pattern = "% A % d % T % u % L % S % B % v % P % R" resolvehosts = "false"/>

After Tomcat is started, the default log file directory is logs,


The specific information format is as follows:

127.0.0.1 37 [05/Jun/2012: 17: 23: 43 + 0800] -- 200 2806 127.0.0.1 8080 get/cdbleasing/message. listmessageprompt. Action? _ Dc = 1338888223333 HTTP/1.1

127.0.0.1 533 [05/Jun/2012: 17: 26: 31 + 0800]--200 25994 127.0.0.1 8080 get/cdbleasing/workflow. listtaskbycandidateuser. Action? _ Dc = 1338888390970 & Title = & author = & processname = & page = 1 & START = 0 & limit = 50 & sort = % 5B % 7b % 22 property % 22% 3A % 22 specified edtime % 22% 2C % 22 direction % 22% 3A % 22 DESC % 22% 7D % 5 dhttp/1.1

 

 

Official configuration instructions:

Values for the pattern attribute are madeup of literal text strings, combined with pattern identifiers prefixed by the "%" character to cause replacement by the corresponding variablevalue from the current request and
Response. The following Pattern Codes aresupported:

  • %-Remote IP Address
  • %-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 ed
  • % Q-Query string (prepended with '? '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
  • % I-Current request thread name (can compare later with stacktraces)

There is alsosupport to write information from the cookie, incoming header, the session orsomething else in the servletrequest. It is modeled after the apachehttp server log configurationsyntax:

  • % {XXX} IFor incoming Headers
  • % {XXX} oFor outgoing Response Headers
  • % {XXX} cFor a specific cookie
  • % {XXX} rXXX is an attribute in the servletrequest
  • % {XXX} sXXX is an attribute in the httpsession

The shorthandpattern name common (which is also the default) corresponds'% H % L % u % t "% R" % S % B'.

The shorthandpattern name Combined appends the values of the Referer and User-Agent headers, each in double quotes, to the common pattern describedin the previous paragraph.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.