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