Objective
Originally prepared to explain the Nginx and Apache logs, but the individual is not recommended Apache (purely personal hobby), here does not introduce the Apache log.
As a programmer, the code is more important than a little bit of the log analysis and query. Common logging and setting methods are listed below.
Configuration file
Nginx Sub-access_log and error_log two kinds of logs
Settings need to be in nginx.conf, the default through the source package compiler installation Nginx directory should be
/usr/local/nginx
Directory, if you install through Yum or other means, unclear or unknown nginx specific installation directory, you can use
Find/-name nginx.conf
Or
Nginx-v | grep prefix-------------nginx version:nginx/1.13.9built by gcc 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) built with OpenSSL 1.0.2k-fips Jan 2017TLS SNI support enabledconfigure arguments:--prefix=/usr/local/nginx--with-http_ssl_ Module
Open Access Log
If your source package is installed by default, open the path as follows
Vim/usr/local/nginx/nginx.conf
Find the following:
HTTP { include mime.types; Default_type Application/octet-stream; Log_format main ' $remote _addr-$remote _user [$time _local] "$request" "$status $body _bytes_sent" $http _ Referer " " "$http _user_agent" "$http _x_forwarded_for"; Access_log logs/access.log main; ...}
Open the Log_format to access_log comment, Log_format can define the log specifications for Nginx.
Log_format Default specification Parameter table
name |
Annotations |
$remote _addr |
IP address of client/user |
$time _local |
Access time |
$request |
Request method + Request Address |
$status |
Request status code consistent with HTTP status code |
$body _bytes_sent |
The requested address size is calculated in bytes format |
$http _referer |
The source of the request, from where it was accessed |
$http _user_agent |
User information (browser information) |
$http _x_forwarded_for |
Forwarding IP Address |
Turn on the error log
If your source package is installed by default, open the path as follows
Vim/usr/local/nginx/nginx.conf
Find the following:
Error_log Logs/error.log, #error_log logs/error.log notice; #error_log logs/error.log info;
Delete the annotations so that you can store the different error types separately, such as
Error_log Logs/error.log Notice;
Notice are both error types and not write all.
Thanks
Thank you for seeing this, log operations and analysis of related articles I will write some, hope can help you. Thank you
Code changeable, beginner's mind unchanged