Windows 中打开httpd.conf配置文件找到:
CustomLog "logs/access.log" common
ErrorLog “error_log”
将其改为:
CustomLog "|bin/rotatelogs.exe logs/%Y_%m_%d_access.log 86400 480" common
ErrorLog "|bin/rotatelogs.exe logs/%Y_%m_%d_error.log 86400 480"
Linux系统中
vi /etc/httpd/conf/httpd.conf #编辑文件
#ErrorLog logs/error_log #注释此行,添加下面这行
ErrorLog "|rotatelogs /var/log/httpd/error_log%Y%m%d.log 86400 480" #每天单独生成一个日志文件
#CustomLog logs/access_log common #注释此行,添加下面这行
CustomLog "|rotatelogs /var/log/httpd/access_log%Y%m%d.log 86400 480" common #每天单独生成一个日志文件
本文详细介绍了如何在Windows和Linux系统下配置Apache的日志轮转,通过修改httpd.conf文件,实现access.log和error_log的日志文件按天进行轮转,以确保服务器日志的高效管理和维护。
2188

被折叠的 条评论
为什么被折叠?



