Nginx logging and formatting, configured in the master configuration file
Vim/usr/local/nginx/conf/nginx.conf
In this line
Log_format combined_realip ' $remote _addr $http _x_forwarded_for [$time _local] '
' $host ' $request _uri "$status"
' "$http _referer" "$http _user_agent";
Combined_realip is the name of the log and can be customized. such as: WYP
$remote _addr Remote IP
$http IP for _x_forwarded_for proxy
[$time _local] Time
$host Domain Name
$request _uri Access Address
$status Status Code
Because the log format is defined in the master configuration file, it needs to be reflected in the virtual host configuration,
Root/usr/local/discuz; Insert the following code:
Access_log/tmp/access.log Combined_realip;
Format of the path and name log of the access log
Next, test it with curl-x127.0.0.1:80 Www.llzdwyp.com/123-I.
Found Access.log log file in/tmp, display/123 no 404 Code Found
If you use curl-x127.0.0.1:80 Www.llzdwyp.com-I to test
Will find a lot of access logs, including JPG, PNG and so on, let's get rid of these unrelated logs
Specify the access log, or use the location of this statement, it is important to note that: Localtion is in order, such as
match the first, do not match, so we defined the user authentication to be placed in front, the specified file type log is placed behind , otherwise you can also log in to the central administration.
Location ~. *\. (gif|jpg|jpeg|png|bmp|swf) $
{
Access_log off;
}
In the log there are many/static/and/cache/directory-independent logs, you can also specify not to log. Write a line above
Insert below the code above:
Location ~ (static|cache)
{
Access_log off;
}
Note: Remember that location has a matching order, this case is admin.php, so the order does not matter.
1.9-nginx log of specified file types is not logged