42ew222 发表于 2016-3-15 09:25:56

Apache日志切割

#vim /usr/local/apache2/conf/extra/httpd-vhosts.conf(把以下两文件的#去掉保存)
ErrorLog "logs/dummy-host.example.com-error_log"
CustomLog "logs/dummy-host.example.com-access_log" combined

common主日志文件
# vim /usr/local/apache2/conf/httpd.conf
# ls /usr/local/apache2/logs/
access_logerror_loghttpd.pid
# /usr/local/apache2/bin/apachectl graceful
# cd /usr/local/apache2/logs/
# ls
access_logdummy-host.example.com-access_logdummy-host.example.com-error_logerror_loghttpd.pid
# cat dummy-host.example.com-access_log(查看访问日志)

日志切割

# vim /usr/local/apache2/conf/extra/httpd-vhosts.conf
ErrorLog "logs/test.com-error_log"
CustomLog "|/usr/local/apache2/bin/rotatelogs -l /usr/local/apache2/logs/test.com-access_%Y%m%d_log 86400" combined

Syntax OK
# /usr/local/apache2/bin/apachectl restart
# ls
access_log                         dummy-host.example.com-error_loghttpd.pid                     test.com-error_log
dummy-host.example.com-access_logerror_log                         test.com-access_20160315_log
# date -s "2016-03-16 01:01:00 "
2016年 03月 16日 星期三 01:01:00 CST
# ls
access_log                         dummy-host.example.com-error_loghttpd.pid                     test.com-access_20160316_log
dummy-host.example.com-access_logerror_log                         test.com-access_20160315_logtest.com-error_log

页: [1]
查看完整版本: Apache日志切割