Use logrotate to poll nginx and Apache Log document directories [Hide]
Configure nginx
Configure Apache
Using logrotate to poll logs is convenient and easy to configure. Configure nginx 1. Create the/etc/logrotate. d/nginx file.
VI/etc/logrotate. d/nginx
2. Write the following content:
/Var/log/nginx/* log {
D
Linux notes: apache configuration and log-Linux Enterprise Application-Linux server application information. For details, refer to the following section. Alibaba Cloud handled apache configuration today:
1. Set Environment Variables
2. Handling leeching Methods
3. Separate and save logs
1. Set Environment Variables
In apach
One, Apache access logs do not log static filesMost of the site elements are static files, tablets, CSS, JS, etc., these elements can not be recordedvim/usr/local/apache2.4/conf/extra/httpd-vhosts.conf//Change to the followingChange the virtual host configuration file to the following:DocumentRoot "/data/wwwroot/www.123.com"ServerName www.111.comServeralias 111.comSetenvif Request_uri ". *\.gif$" imgSetenvi
Article Title: Linux Server: Apache configuration and logs. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
1. Set Environment Variables
In apache, you can use regular expressions to determine many variables, and then set anot
Use AWK to process Apache logs
Introduction to Awk:
Born in 1970 to Bell Labs, AWK is a programming language for processing text data, named after the first letter of 3 authors (Alfred Aho, Peter Weinberger, and Brian Kernighan), gawk for GNU awk.
Chang:
Number of ARGC command line argumentsARGV command line variable arrayFileName current input filenameFNR the record number in the current fileFS input field
The package that parses the logCompile yourself:packageApacheLogParser.jarIt's good to have simple analysis of grep for access logs, but more complex queries require spark.Code:Import Com.alvinalexander.accesslogparser._val p =NewAccesslogparservalLog= Sc.textfile ("Log.small")//log.count//analyze the Apache log in 404 how manyDef getstatuscode ( Line: Option[accesslogrecord]) = { LineMatch { CaseSome (L) =
If you limit the log file size to 800M and the file is automatically cut beyond that size, you can set the followingCustomlog "|/www/lanmps/apache/bin/rotatelogs/www/wwwlogs/logs/www.lanmps.com/%y_%m_%d.access.log 86400 800M "CommonFor an explanation of the Apache rotatelogs function, see http://88fly.blog.163.com/blog/static/122680390201293172154395/
Apache 2.4.4 Automatically splits logs, which are generated by year, month, and day. apache2.4.4
If the size of the log file is limited to 800 mb and the file size is exceeded, you can set it as follows:
CustomLog "|/www/lanmps/apache/bin/rotatelogs/www/wwwLogs/logs/www.lanmps.com/policy_0000m_0000d.access.log
/db/HTTP/1.1"This is the most useful one. First, it tells our server to receive a GET request, second, the resource path of the client request, and third, HTTP/1.1 when the client uses the protocol, the entire format is "% m % U % q % H", that is, "request method/access path/protocol"(6) 200This is a status code sent back to the client by the server. it tells us whether the client's request is successful, or is redirected, or what kind of error is encountered. The value is 200, indicates that th
I sometimes find that the network name specified by [Fri Mar 16 17:28:49 2007] [warn] (OS 64) is no longer available in my apache logs. : Winnt_accept: Asynchronous AcceptEx failed. For this type of error, I will share the solution below.
Error Analysis
The network name specified by [Fri Mar 16 17:28:50 2007] [warn] (OS 64) is no longer available. : Winnt_accept: Asynchronous AcceptEx
Failed.
AcceptEx () is
1, the number of IP direct output display:Cat Access_log_2011_06_26.log |awk ' {print $} ' |uniq-c|wc-l2, the number of IP output to the text display:Cat Access_log_2011_06_26.log |awk ' {print $} ' |uniq-c|wc-l > Ip.txtSummary: If a single access log is larger than 2G, the system load will rise when viewed with this command, so do not view when the server is under high load, preferably in a low load time period. The above is one of the company's advertising server a day of IP access, which actu
my need is to www.aaa.com/aaa/a similar request ... The log is logged only for such requests. Add in httpd.conf or the associated virtual host configuration filesetenvifrequest_uri "^/aaa/.*" aaa-requestCustomLog "|/usr/local/apache/bin/rotatelogs -l/usr/local/apache/logs/aaa-access_%y%m%d.log86400 "combinedenv=aaa-request that's all you can do. This principle is
Example The code is as follows:Copy code ErrorLog "xxx/log/error2.log"LogFormat "% h % l % u % t" % r "%> s % B" % {Referer} I "" % {User-Agent} I "combinedCustomLog "xxxx/log/logweb‑2.log" combined Generated logs The code is as follows:Copy code /Database/110/0 db40c45cfdb980cdffa1d0cffb2891c.htm HTTP/1.1 "200 2992"-"" YisouSpider"118.186.139.156--[22/Nov/2013: 1
1, Customlog "|bin/rotatelogs.exe logs/access_%y_%m_%d.log 86400 480" combinedChange it here to show, and then restart Apache. After rebooting, such as:He's going to open a command-line window that's always guarded and can't be shut off. You can also delete the log file with the date and then turn off the command window. Command WindowWhen you turn it off, you start it yourself again, and the new log file i
1, the number of IP direct output display:cat access_log_2011_06_26.log |awk ‘{print $1}‘|uniq -c|wc -l2, the number of IP output to the text display:cat access_log_2011_06_26.log |awk ‘{print $1}‘|uniq -c|wc -l > ip.txtSummary: If a single access log is larger than 2G, the system load will rise when viewed with this command, so do not view when the server is under high load, preferably in a low load time period. The above is one of the company's advertising server a day of IP access, which actu
The LogFormat parameter of apache logs is described in the apache configuration file httpd. by default, logformat "% h % l % u % t \" % r \ "%> s % B \" % {Referer} I \ "is configured in conf \"\" % {User-Agent} I \ "" common this is APACHE log record format settings, what do the parameters in this format mean? The fol
Linux under the Cronolog partition Apache log, big god mo shoot Bricks, rookie left a record, small white please silently reproduced. Not even the Linux login and VI edit, please close this page silently. Into the chaseDescription: The light green bottom for the Linux command, the other for the note description.Download Cronolog wget "Http://download.chinaunix.net/down.php?id=3457ResourceID =1851site=1 " #解压缩 TAR-XZVF cronolog-1.6.2.tar.gz #进入目录
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.