Nginx log management

Check Nginx's nginx.conf file, and you can see such a message

#access_log  logs/access.log  main;

This indicates that the file of the server access log is logs/host.access.log in the format of "main".

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"';

#Parameter interpretation
$remote_addr Client IP Address;
$remote_user Client user name;
$time_local Time and time zone visited;
$request The type of access request, POST perhaps GET´╝Ť
$status Record request status,404,304,200Wait;
$body_bytes_sent The size of the file body content sent by the client to the server;
$http_referer Access source - from which link;
$http_user_agent User agent information is generally the mark of browser, sometimes it is also the mark of crawler.
$http_x_forwarded_for Direct access to the IP Address, possibly client IP It could also be a proxy server IP

#Log instance in main format
47.97.66.214 - - [05/May/2018:02:18:26 +0800] "GET /solr/ HTTP/1.1" 404 571 "http://44.186.245.237/solr/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36"
47.97.66.214 - - [05/May/2018:02:18:26 +0800] "GET /wcm/ HTTP/1.1" 404 571 "http://44.186.245.237/wcm/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36"
80.82.78.50 - - [05/May/2018:03:53:56 +0800] "GET http://www.baidu.com/cache/global/img/gs.gif HTTP/1.1" 404 169 "-" "Mozilla"
112.193.171.197 - - [05/May/2018:06:52:06 +0800] "GET http://www.rfa.org/ HTTP/1.1" 200 462 "-" "python-requests/2.6.0 CPython/2.7.5 Linux/3.10.0-693.11.1.el7.x86_64"

In addition to the main format, you can customize other formats by recombining the above parameters.

The default log of nginx is stored in logs/access.log, but different logs are allowed for different servers. Only the following statements need to be added under the corresponding server

access_log logs/access_8080.log mylog;
#Declare alog #logStorage directory and name #logformat(Customizable)

After modifying nginx.conf, you need to restart Nginx for the configuration to take effect

Keywords: Nginx solr Windows Python

Added by TonyB on Fri, 20 Mar 2020 17:53:01 +0200