In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Nginx Log Description
Through the access log, you can get information about the user's geographical origin, jump source, terminal usage, access volume of a URL, etc. Through the error log, you can get the performance bottleneck of a service or server in the system. Therefore, make good use of the journal, you can get a lot of valuable information.
Parameter list:
$remote_addr IP address of client (proxy server, showing proxy service ip)$remote_user Used to record user name of remote client (usually "-")$time_local Used to record access time and time zone $request Used to record url and request method $status Response status code, for example: 200 success, 404 page not found.$ body_bytes_sent The number of bytes of the file body sent to the client $http_user_agent The proxy used by the user (usually a browser)$http_x_forwarded_for can record the IP address of the client, and record the IP address of the client through the proxy server $http_referer can record the link from which the user accessed it.
Nginx Log Separation
Nginx log files do not have rotate functionality. Write to generate a log every day, we can write an nginx log cutting script to automatically cut log files.
The first step is to rename the log file, do not worry about renaming nginx can not find the log file and lose the log. Nginx will still log to the file you renamed until you reopen the log file with the original name. Linux locates files by file descriptors rather than file names.
The second step is to send the USR 1 signal to the nginx master process. When the nginx master process receives the signal, it reads the log file name from the configuration file, reopens the log file (named after the log name in the configuration file), and takes the user of the worker process as the log file owner. After reopening the log file, the nginx master process closes the log file with the duplicate name and notifies the worker process to use the newly opened log file. The worker process immediately opens the new log file and closes the log file with the duplicate name. Then you can deal with old log files. [or restart nginx service].
Nginx Log Format
Open the nginx. conf configuration file: vim/usr/local/nginx/conf/nginx. conf
Looking at Nginx's nginx. conf file, you can see this message
#access_log logs/access.log main;
This means that the file of the server access log is logs/host.access.log, using the format "main".
Log generation to the Nginx root directory logs/access.log file, default to the "main" log format, you can also customize the format.
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"';#Parameters Explanation $remote_addr Client IP address;$remote_user client username;$time_local Time and time zone of access;$request Type of access request, POST or GET;$status Record request status, 404, 304, 200, etc.;$body_bytes_sent Size of file body content sent by client to server;$http_referrer Access source--from which link;$http_user_agent user agent information, usually browser tags, sometimes crawler tags.$ http_x_forwarded_for directly accessing the IP address of the server, which may be the client IP or the proxy server IP #Apply log instance in main format 47.97.66.214--[05/May/2018: 02:18:26 +0800]"GET/solr/HTTP/1.1" 404 571 "www.example.com""Mozilla/5.0 (Windows NT 10.0; Win 64; x64) AppleWebKit/537.36 (KHTML, li Gecko) Chrome/59.0.3071.115 Safari/537.36" www.example.com--[05/May/2018: 02:18:26 +0800]"GET/wcm/HTTP/1.1" 404 571 "www.example.com""Mozilla/5.0 (Windows NT 10.0; Win 64; x64) AppleWebKit/537.36 (KHTML, li Gecko) Chrome/59.0.3071.115 Safari/537.36" www.example.com--[05/May/2018: 03:53:56 +0800]"GET www.example.com HTTP/1.1" 404 169"-" Mozilla" www.example.com--[05/May/2018: 06:52:06 +0800]" GET www.example.com HTTP/1.1" 200 462"-"" python-requests/2.6.0 CPython/2.7.5 Linux/3.10.0 - 6 93.11.1.el7.x86_64"
In addition to the main format, you can customize other formats by simply recombining the above parameters.
The default log of nginx is stored in logs/access.log, but it is also allowed to make different logs for different servers. Just add the following statement under the corresponding server.
access_log logs/access_8080.log mylog;#Declare a log #log Store directory and name #log format (customizable)
After modifying nginx. conf, you need to restart nginx to make the configuration take effect.
summary
The above is all the content of this article, I hope the content of this article for everyone's study or work has a certain reference learning value, thank you for your support. If you want to know more about this, please check out the links below.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.