您的位置:首页 > 运维架构 > Apache

rotatelogs分割apache日志文件

2015-11-13 15:59 645 查看
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"
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: