The Tomcat log analysis is detailed

Source: Internet
Author: User

Under the

<valve classname= "Org.apache.catalina.valves.AccessLogValve"

directory= "Logs" prefix= "Localhost_access_log." suffix= ". txt"

pattern= "Common" resolvehosts= "false"/>

So, let's analyze each parameter individually.

ClassName

The official document says this must is set to Org.apache.catalina.valves.AccessLogValve to use the default access log valve. &<60; Want to configure access logs? It has to be written like this.

Directory

This thing is the log file placed directory, under Tomcat there is a logs folder, which is specifically placed in the log file, of course, you can also modify, I changed to D:

Prefix

This is the name prefix of the log file, my log name is localhost_access_log.2007-09-22.txt, the preceding prefix is this localhost_access_log

Suffix

This is the suffix, it can be changed into something else.

Pattern

This is the main parameter, the specific we say below, the content of this parameter is quite rich.

Resolvehosts

If this value is true, Tomcat translates the server IP address through DNS to the hostname, and if it is false, it writes the server IP address directly.

There are also some parameters:

Rotatable

The default is true, and the default setting makes your tomcat-generated file prefix (prefix) +.+ time (usually by day) +.+suffix (suffix), as you can see with my log name: Localhost_access_ Log.2007-09-22.txt

Use this with caution, because if you set it to false, Tomcat ignores the time, does not create a new file, and eventually causes your file to be super large, so the resulting file name is: Localhost_access_log.txt

Condition

This parameter is not very practical, can set any value, such as we set to Condition= "TKQ", then only when Servletrequest.getattribute ("TKQ") is empty, it will be recorded

Filedateformat

The last parameter, very clear, this is the time format, but this time format is for the log file function, remember we generated the full name of the log file: Localhost_access_ Log.2007-09-22.txt, this is the 2007-09-22, if you want Tomcat to generate a log file every hour, it is also very simple, set this value to: filedateformat= "Yyyy-mm-dd.hh", Of course, you can create something by the minute, change it yourself

The above is all 9 parameters, just now we said, pattern this parameter value is more, we take down to say separately:

Pattern can be set in two ways, the first is pattern= "common", the second is pattern= "combined"

This can control the format of the log, you said, pattern on these two? What does common and combined mean?

What format do you think it is?

Don't worry, we look at 1.1, in fact, the pattern is can be set, common and combined just integrated a few explicit

Shows the way, is the display way to the combination, the actual value of pattern has the following, is a letter, the front

A percent percent sign

Let's put out a record in my log, which corresponds to the view

127.0.0.1 192.168.254.108--1 127.0.0.1 http/1.1-get 80&<60; get/rightmainima/leftbott4.swf http/1.1 304 5563a67708646b6aa299c33d59be132a [22/sep/2007:10:08:52 +0800]-/ rightmainima/leftbott4.swf localhost 0 0.000

%a

This is the IP of the record visitor, which is 127.0.0.1 in the log.

%A

This is the IP of the ground server, which is 192.168.254.108 in the log.

%b

This is the number of bytes to send the message, not the HTTP header, if the number of bytes is 0, displayed as-

%B

Look at Tomcat's explanation, did not see the difference with the b%, but I show here as-1, do not want to understand, hope to know the person told, I put the official explanation posted it Bytes sent, excluding HTTP headers

%h

This is the server name, if Resolvehosts is false, here is the IP address, my log is 127.0.0.1

%H

Visitors use the protocol, here is http/1.1

%l

This is also not clear, the official said that always return '-' official explanation: Remote logical username from Identd (possibly translated: record the browser to provide the name of authentication) (always returns '-')

%m

Access the way that is get or post I this is get

%p

Locally received access to the port, hehe, I'm 80 here.

%q

For example, you visit the AAA.JSP?BBB=CCC, then this shows BBB=CCC, understand, this q is querystring meaning

%r

Official explanation: First line of the request (method and request URI), not very clear

%s

This is the status of HTTP, I return here is 304, we often see a page report error 500 or something, that will return 500

%s

User's session ID, this session ID you can also check the detailed explanation, anyway each time will generate a different session ID

%t

This is the time, there seems to be a common Log format can be changed, but I did not find

%u

A visitor who has been authenticated, or "-"

%u

Access to the URL of the address I'm here is/rightmainima/leftbott4.swf

%v

Server name, maybe that's what you wrote in the URL, I'm localhost here.

%d

Official explanation: Time taken to process the request, in Millis, should be visited in milliseconds

%T

Official explanation: Time taken to process the request, in seconds, should be visited in seconds

The Tomcat log analysis is detailed

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.