rotatelogs分割apache日志文件

rotatelogs 截断日志,进行配置。但是保存httpd.conf 之后,服务器报错:

日志文件:

piped log program ' /usr/sbin/rotatelogs logs/pyzx_access_log.%Y_%m_%d.log 86400 480' failed unexpectedly
447 Could not open log file 'logs/pyzx_access_log.2015_11_13.log' (No such file or directory)

解决办法:

 1)rotatelogs 不能直接写 rotatelogs,必须写完整地址  /usr/sbin/rotatelogs 

2)rotatelogs 无创建目录的权限,所以最好不要给 格式化的地址加文件夹,写成完全路径。

正确的写法:

注意:这个如果启用虚拟路径的话可以写到<VirtualHost *:80>节点中
CustomLog "| /usr/sbin/rotatelogs var/log/httpd/pyzx_access_log.%Y_%m_%d.log 86400 480" combined

默认错误日志文件只有一个,如果要分割:写法如下:

ErrorLog "| /usr/sbin/rotatelogs /var/log/httpd/error_log_%Y%m%d.log 86400 480"

 

posted @ 2015-11-13 15:59  wuling129  阅读(993)  评论(0编辑  收藏  举报