Nginx and Apache Log formats

Source: Internet
Author: User
Tags apache log

Nginx:

Log_format main '$ remote_addr-$ remote_user [$ time_local] "$ request "'
'$ Status $ body_bytes_sent "$ http_referer "'
'"$ Http_user_agent" $ request_time ';

Log format description:
$ Remote_addr IP Address used for remote request
$ Remote_user remote login name
$ Time_local time, in common log time format (Standard English format)
$ The first line of the request
$ Status.
$ Body_bytes_sent the number of bytes returned by the request, including the data in the request header.
$ Http_referer content of the Referer Request Header
$ Http_user_agent content of the User-Agent Request Header
$ Request_time the time taken to process the request, in seconds

 

Apache:

LogFormat "% h % l % u % t \" % r \ "%> s % B \" % {Referer} I \ "\" % {User-Agent} I \ "% T" combined
CustomLog log/access_log combined

Log format description:

% A remote IP Address

% A local IP Address

% B number of bytes transmitted except the HTTP Header

% B indicates the number of bytes transmitted except the HTTP header in CLF format, that is, '-' rather than 0 is displayed when no Bytes are transferred.

The content of cookieFoobar that % {Foobar} C sends to the server in the request.

% D the time used by the server to process this request, in microseconds. (% D logs the time between Apache starting to process a request (I. e. I believe it omits the handshake) and offloading it completely onto the local TCP stack. you cannot measure just the time it takes to process the request and compose the response .)

% {FOOBAR} e environment variable FOOBAR Value

% F file name

% H remote host

Protocol used by the % H request

% {Foobar} I content of the Request Header Foobar: sent to the server.

% L remote login name (provided by identd, if supported), a "-" will be obtained unless IdentityCheck is set to "On "-".

% M Request Method

% {Foobar} n is the content of the annotation Foobar from another module.

% {Foobar} o Response Header Foobar: content.

% P server serves the standard port of the request.

% P is the PID of the subprocess that serves the request.

% {Format} P serves the PID or TID (thread ID) of the request. The value range of format is pid and tid (2.0.46 and later versions) and hextid (APR1.2.0 or a later version is required)

% Q query string (If yes, "? "Boot; otherwise, an empty string is returned)

% R the first line of the request

% S status. For internal redirection requests, this status refers to the status of the original request, and-%> s refers to the status of the final request.

% T time, in common log time format (Standard English format)

% {Format} t time, in the format specified by strftime (3. (By default, the local format is used)

% T the time taken to process the request, in seconds.

% U remote user name (based on authentication information; if the returned status (% s) is 401, it may be false)

The URL path of the % U request, excluding the query string.

% V standard ServerName that provides services for this request.

% V indicates the server name set according to the UseCanonicalName command.

% X connection status when the request is completed: X = the connection is interrupted before the response is completed.

+ = Keep the connection after the response is sent.

-= Close the connection after the response is sent.

(In Versions later than 1.3, this command is % c, but this is in conflict with the previous SSL Syntax: % {var} c)

The number of bytes received by % I, including the data in the request header, and cannot be zero. To use this command, you must enable the mod_logio module.

The number of bytes sent by % O, including the data in the request header, and cannot be zero. To use this command, you must enable the mod_logio module.

Modifier

 

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %T/%D" combined

Example:

[31/Jan/2008:14:19:07 +0000] "GET / HTTP/1.1" 200 7918 "" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.11) Gecko/20061201 Firefox/2.0.0.11 (Ubuntu-feisty)" 0/95491

 

Appendix:

Apache processes persistent connections:

case:http://blogread.cn/it/article.php?id=2042 

Conclusion:In an ideal environment, if a persistent connection is enabled, the system can handle 6 k/s responses. If a persistent connection is disabled, the system can only handle 4.2 k/s responses. I think the actual environmental impact must be much smaller. However, to some extent, persistent connections are quite useful.

KeepAlive is the decision to enable KeepAlive support. KeepAliveTimeout determines how long a KeepAlive connection can be maintained, and Timeout will shut down the link as soon as possible. If there is still data, a new connection must be established. MaxKeepAliveRequests is similar to KeepAlive, it means that the shutdown connection is enabled for the number of requests to be served. Let's look at an example:

KeepAlive OnKeepAliveTimeout 5

It means that when KeepAlive is enabled, each connection is interrupted for only 5 seconds.

Exercise caution when configuring KeepAlive. Incorrect parameters may cause serious performance problems. If a high-load Server creates many persistent connections, it will not be able to continue service new connections. Therefore, you must adjust the value of KeepAliveTimeout or MaxKeepAliveRequests based on the nature of the server.

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.