System in the daily work will record a lot of file logs, if they are placed in a, we in the collation of the search, will be very cumbersome, increase the workload, so we have to use the log cutting, so that we classify the archive.
First, edit the virtual host configuration file
[Email protected] ~]# vim/usr/local/apache2/conf/extra/httpd-vhosts.conf
We'll open the Customlog and errorlog and change the URL to our main domain,
Errorlog "Lam.com-error_log"
Customlog "Lam.com-access_log" common
(Add: We can view the log file in the "Log directory":/usr/local/apache2/logs directory. )
Then we edit the "Master profile"
[Email protected] ~]# vim/usr/local/apache2/conf/httpd.conf
Query/common, find
Logformat "%h%l%u%t \"%r\ "%>s%b \"%{referer}i\ "\"%{user-agent}i\ "" Combined
We know that combined is better than common and can use custom formats like Combinedio,
(%h is ip,%u is the user,%t is the time,%r is the action ,%{referer}i is the Forum homepage)
So here we use combined, To edit a virtual host configuration file:
Customlog "Lam.com-access_log" common changed to combined, i.e.
Customlog "Lam.com-access_log"combined
Finally, 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.conf
Errorlog 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] ~]# Apachectl-restart
View the log directory
[Email protected] ~]# Ls/usr/local/apache2/logs
Error_log Lam.com-access_20150711_log
Apache Log Cutting