Apache日志切割
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Apache日志切割相关的知识,希望对你有一定的参考价值。
[[email protected] ~]# 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主日志文件
[[email protected] ~]# vim /usr/local/apache2/conf/httpd.conf
[[email protected] ~]# ls /usr/local/apache2/logs/
access_log error_log httpd.pid
[[email protected] ~]# /usr/local/apache2/bin/apachectl graceful
[[email protected] ~]# cd /usr/local/apache2/logs/
[[email protected] logs]# ls
access_log dummy-host.example.com-access_log dummy-host.example.com-error_log error_log httpd.pid
[[email protected] logs]# cat dummy-host.example.com-access_log (查看访问日志)
日志切割
[[email protected] ~]# 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
[[email protected] ~]# /usr/local/apache2/bin/apachectl restart
[[email protected] logs]# ls
access_log dummy-host.example.com-error_log httpd.pid test.com-error_log
dummy-host.example.com-access_log error_log test.com-access_20160315_log
[[email protected] logs]# date -s "2016-03-16 01:01:00 "
2016年 03月 16日 星期三 01:01:00 CST
[[email protected] logs]# ls
access_log dummy-host.example.com-error_log httpd.pid test.com-access_20160316_log
dummy-host.example.com-access_log error_log test.com-access_20160315_log test.com-error_log
本文出自 “mr guo” 博客,请务必保留此出处http://490617581.blog.51cto.com/7223113/1751102
以上是关于Apache日志切割的主要内容,如果未能解决你的问题,请参考以下文章