Nginx Log Management

Source: Internet
Author: User

One: Nginx Log Management
We observe the Nginx server segment and can see similar information as follows #access_log logs/Host.access.log Main; This indicates that the server, its access log file is logs/Host.access.log, using the format "main" format. In addition to the main format, you can customize other formats. What is the main format ??Log_format Main'$remote _addr-$remote _user [$time _local] "$request"'    #                  '$status $body _bytes_sent "$http _referer"'    #                  '"$http _user_agent" "$http _x_forwarded_for "'The main format is that we define a log format and name it for easy reference. In the example above, the main type of log, recorded by the remote_addr .... http_x_forwarded_for options.1: The log format refers to which options are recorded by default log format: main Log_format main'$remote _addr-$remote _user [$time _local] "$request"'                            '$status $body _bytes_sent "$http _referer"'                            '"$http _user_agent" "$http _x_forwarded_for "', such as the default main log format, which records so many remote IP-Remote user/User Time request method (e.g. get/POST) Request Body Body length Referer source information http-user-agent User Agent/Spider, the original iphttp_x_forwarded_for of the forwarded request: at the time of the agent, the agent put your original IP in this header message, transfer your raw IP2: Declare a unique Log_format and name Log_format mylog'$remote _addr-"$request"'                     '$status $body _bytes_sent "$http _referer"'                        '"$http _user_agent" "$http _x_forwarded_for "'; In the following server/Location , we can refer to MyLog in the server segment to declare that Nginx allows different logs for different servers (some Web server does not support, such as Lighttp) Access_log logs/Access_8080.log MyLog; Declare log log location log format; Practical application: Shell+ Timed Tasks +Nginx Signal Management, complete the log by Date storage analysis idea: Early morning XX:xx: on, rename yesterday's log, put in the corresponding directory and then USR1 information number control Nginx regenerate new log file

Nginx Log Management

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.