日期:2014-05-17  浏览次数:20798 次

Apache日志滚动和过滤

终于是可以让Apache不产生超大的日志了。

?

原文

#CustomLog "logs/access.log" combined

?

改为
SetEnvIf Request_URI "\.(js|css|gif|jpg|png|swf|ico)$" dontlog
SetEnvIf Request_URI "\.(html|htm)$" dontlog

????
CustomLog "|bin/rotatelogs.exe logs/access.%Y_%m_%d.log 86400 480" common env=!dontlog

?

其中SetEnvIf 表示是否匹配URI,结果为dontlog,多行按或的关系处理,写日志是env=!dontlog,表示不匹配的才写入日志。

?

86400是一天的秒数,文件滚动周期。

?

480当地时间与标准时的时差分钟数这里取北京时间GMT+8。