The site will increase with the amount of traffic, and the log becomes more and more large, if ignored, will someday burst disk.So we should cut the log regularly every day, such as one months later, and then delete the outdated logs to ensure that the log files will not be an infinite amount of disk-occupying resources.configuration: to enter Apache virtual Host configuration file, modify Errorlog Customelog Two lines of fields, using the Bin direct
#vim/usr/local/apache2/conf/extra/httpd-vhosts.confOpen two lines of comments (Errorlog and Customlog), generate access and errors corresponding to the log, of course, you can also modify the default generated file nameThen change the last face of Customlog to combined, because I use the combined type#apache1 Restart #重启一下apache服务Go to refresh the Web page (generate log)#ls/usr/local/apache2/logs/#到这里就可以看见生成的日志了Below is the format of the cut:vim/usr/l
What we're saying here about Apache's log is the thing about the access log! To prevent log files from being too large, we archive the logs on a daily basis!Vim/usr/local/apache2/conf/extra/httpd-vhosts.confOpen the virtual machine configuration file and remove the # number in front of the following two linesErrorlog "Logs/dummy-host2.example.com-error_log" Customlog "Logs/dummy-host2.example.com-access_log" commonThen restart the Apache service and v
Apache is still relatively cool, with its own Rotatelog program, edit the Apache master configuration file, the following changes:Comment out the following two linesErrorlog Logs/error_logCustomlog Logs/access_log CommonThen add the following two linesErrorlog "|bin/rotatelogs logs/errorlog.%y-%m-%d-%h_%m_%s 2M +480″Customlog "|bin/rotatelogs logs/accesslog.%y-%m-%d-%h_%m_%s 2M +480″commonThe meanings are a
that the resulting log is passed to Rotatelogs, which is the tool for Apache's own cut logs. The function of-L is to calibrate the timezone to UTC, Beijing time. The last side of 86400, the unit is the second, meaning a day. The combined for double cited is the log format, which defines the log format in/usr/local/apache2/conf/httpd.conf.[[email protected] ~]# grep logformat/usr/local/apache2/conf/httpd.conf logformat "%h%l%u%t \"%r\ "%>s%b \"%{re Ferer}i\ "\"%{user-agent}i\ "" Combined Logform
[Email protected] ~]# vim/usr/local/apache2/conf/extra/httpd-vhosts.conf650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/79/0B/wKiom1aFRH6w3lq9AAA06EYUr9E441.png "title=" Qq20151231231320.png "alt=" Wkiom1afrh6w3lq9aaa06eyur9e441.png "/>common represents the type name of the access log, we look at a configuration file, in the main profile we can see the format of the log, Name lookup/common650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M01/79/09/wKioL1aFRYahPobIAABAAfpV9fk109.p
. ___________________________________________________________Log polling production environment actual configuration___________________________________________________________Actual configuration of common production environments polled by day:[[emailprotected]_server]vim/usr/local/apache2/conf/extra/httpd-vhosts.conf___________________________________________________________Logging proxy IP and real client:[[emailprotected]_server~]#vim/usr/local/apache2/conf/httpd.conf #LogFormat "%h%l%u%t\"
Apache will generate access logs and error logs by default under/usr/local/apache2/logs after the service is available Access_log and error_logIn particular, the access log, in the case of multiple user access, will produce a lot of records. Over time, it may turn into a few g or more than 10 g.In order to alleviate this situation, cutting logs by day, deleting previously useless logs, is a good workaround.
"Lam.com-access_log"combinedFinally, we need to archive the logs on a daily basis, i.e. "cut", and delete the old logs.Edit a virtual host configuration file[Email protected] ~]# vim/usr/local/apache2/conf/extra/httpd-vhosts.confErrorlog information is too small, do not need to show too meticulous, generally do not change;customlog "|/usr/local/apache2/bin/rotatelogs-l/usr/local/apache2/logs/lam.com-access_%y%m%d_log 86400" combined: Wq[Email protected] ~]# apachectl-t[Email protected] ~]# Apac
with '-' representation%t time%r action, GET or post5. Edit the virtual host configuration file to define how the log is cut:DocumentRoot "/tmp/123"ServerName invalid.comDocumentRoot "/data/www"ServerName www.test.comServeralias www.mydiscuz.comServeralias www.others.comErrorlog "Logs/test.com-error_log"Customlog "| /usr/local/apache2/bin/rotatelogs-l/usr/local/apache2/logs/test.com-access_%y%m%d_log 86400 "combinedRewriteengine onRewritecond%{http_host} ^www.mydiscuz.com$ [OR]Rewritecond%{http
Date and time under this locale (e.g.: "Sun Dec 14:12:47 GMT 1996")D Number of days in the month (01:31)J Number of days in the current year (001:366)M number of months (01:12)The number of weeks in the current year, beginning with Sunday as a week, with the first week of the week including Sunday (00..53)W the number of weeks in the current year, with Monday as the beginning of the week, the first week of which included the week of Sunday (00..53)W working days (0:6, 0 = Sunday)X the date repr
=1ajaxtarget=plugin_notice http/1.1 "200 63There will be a lot of logs every day, how to deal with it?# vim/usr/local/apache2/conf/extra/httpd-vhosts.confErrorlog "Logs/test.com-error_log"Customlog "|/usr/local/apache2/bin/rotatelogs-l/usr/local/apache2/logs/test.com-access_%y%m%d_log 86400" combined86400s== Day# Ls/usr/local/apache2/logs This time the log is divided by dayTest.com-access_20151214_log Test.com-error_logHow does Apache do not log the s
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.