588创业论坛

标题: Apache 限制日志文件大小和生成时间的方法 [打印本页]

作者: 农民站长    时间: 2013-10-30 12:03
标题: Apache 限制日志文件大小和生成时间的方法
清除error.log、access.log并限制Apache日志文件大小的方法
Apache下的access.log和error.log文件从安装服务器到现在没有动过,今天突然discuz 的MYSQL数据库连接错误,提示2003 错误,检查发现原来是error.log、access.log爆满,文件达到30个G,奶奶的,立马搜索,得把这两个小子干掉。

下面是在网上搜索到的方法,立马见效,顶一个!

在 Windows 下的设置例子如下:
第一步:删除 Apache2/logs/目录下的 error.log、access.log文件

第二步:打开 Apache 的 httpd.conf配置文件并找到下面两条配置

ErrorLog logs/error.log
CustomLog logs/access.log common

直接注释掉,换成下面的配置文件。


# 限制错误日志文件为 1M
ErrorLog “|bin/rotatelogs.exe -l logs/error-%Y-%m-%d.log 1M”

# 每天生成一个错误日志文件
#ErrorLog “|bin/rotatelogs.exe -l logs/error-%Y-%m-%d.log 86400″

# 限制访问日志文件为 1M
CustomLog “|bin/rotatelogs.exe -l logs/access-%Y-%m-%d.log 1M” common

# 每天生成一个访问日志文件
#CustomLog “|bin/rotatelogs.exe -l logs/access-%Y-%m-%d.log 86400″ common




欢迎光临 588创业论坛 (http://bbs.588cy.com/) Powered by Discuz! X2.5