先在服务器上找到:httpd.conf
/usr/local/apache2/conf/httpd.conf
1)先备份;
2)修改该文件中的内容,一个是错误日志,还是一个是访问日志:
#ErrorLog "logs/error_log"
ErrorLog "|/usr/local/apache2/bin/rotatelogs /home/jiangwei/logs/apache2/logs/error-%Y-%m-%d.log 86400"
#CustomLog "logs/access_log" common
CustomLog "|/usr/local/apache2/bin/rotatelogs /home/jiangwei/logs/apache2/logs/access-%Y-%m-%d.log 86400" common
修改后保存
3)重启apache
/usr/local/apache2/bin/apachectl restart
4)检查运行效果
效果如下:cd到/home/jiangwei/logs/apache2/logs/这个目录下ll看到已经生成了今天的两个文件
-rw-r--r-- 1 root root 69602 Jan 20 17:27 access-2018-01-20.log
-rw-r--r-- 1 root root 180652 Jan 20 17:27 error-2018-01-20.log