规范的apache日志文件
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
SetEnvIf Request_URI \.css$ gif-image
SetEnvIf Request_URI \.mid$ gif-image
SetEnvIf Request_URI \.swf$ gif-image
SetEnvIf Request_URI \.mmf$ gif-image
SetEnvIf Request_URI \.wma$ gif-image
SetEnvIf Request_URI \.midi$ gif-image
SetEnvIf Request_URI \.ani$ gif-image
SetEnvIf Request_URI \.rar$ gif-image
SetEnvIf Request_URI \.rarZ$ gif-image
SetEnvIf Request_URI \.mp3$ gif-image
SetEnvIf Request_URI \.zip$ gif-image
SetEnvIf Request_URI \.rmvb$ gif-image
SetEnvIf Request_URI \.txt$ gif-image
SetEnvIf Request_URI \.exe$ gif-image
SetEnvIf Request_URI \.xml$ gif-image
SetEnvIf Request_URI \.ico$ gif-image
SetEnvIf Request_URI bd\.php$ gif-image
SetEnvIf Request_URI counter\.php$ gif-image
SetEnvIf Request_URI comment\.php$ gif-image
SetEnvIf Request_URI emotion\.php$ gif-image
SetEnvIf Request_URI pn\.php$ gif-image
SetEnvIf Request_URI getjs\.php$ gif-image
SetEnvIf Request_URI javascript\.php$ gif-image
SetEnvIf Request_URI vars\.php$ gif-image
SetEnvIf Request_URI vars\.php$ gif-image
SetEnvIf Request_URI redirect\.php$ gif-image
CustomLog "|/usr/local/apache2/bin/rotatelogs /usr/local/apache2/logs/bbs_access_log_%Y%m%d 86400 480" combined env=!gif-image
上面这段配置的意思就是将上面所有SetEnvIf Request_URI规定的文件名都不统计
同时为了只保留两天的日志可以在crontab中建立个计划任务
30 0 * * * find /usr/local/apache2/logs -name "*access*" -mmin +1440 -exec rm {} \;
SetEnvIf Request_URI \.css$ gif-image
SetEnvIf Request_URI \.mid$ gif-image
SetEnvIf Request_URI \.swf$ gif-image
SetEnvIf Request_URI \.mmf$ gif-image
SetEnvIf Request_URI \.wma$ gif-image
SetEnvIf Request_URI \.midi$ gif-image
SetEnvIf Request_URI \.ani$ gif-image
SetEnvIf Request_URI \.rar$ gif-image
SetEnvIf Request_URI \.rarZ$ gif-image
SetEnvIf Request_URI \.mp3$ gif-image
SetEnvIf Request_URI \.zip$ gif-image
SetEnvIf Request_URI \.rmvb$ gif-image
SetEnvIf Request_URI \.txt$ gif-image
SetEnvIf Request_URI \.exe$ gif-image
SetEnvIf Request_URI \.xml$ gif-image
SetEnvIf Request_URI \.ico$ gif-image
SetEnvIf Request_URI bd\.php$ gif-image
SetEnvIf Request_URI counter\.php$ gif-image
SetEnvIf Request_URI comment\.php$ gif-image
SetEnvIf Request_URI emotion\.php$ gif-image
SetEnvIf Request_URI pn\.php$ gif-image
SetEnvIf Request_URI getjs\.php$ gif-image
SetEnvIf Request_URI javascript\.php$ gif-image
SetEnvIf Request_URI vars\.php$ gif-image
SetEnvIf Request_URI vars\.php$ gif-image
SetEnvIf Request_URI redirect\.php$ gif-image
CustomLog "|/usr/local/apache2/bin/rotatelogs /usr/local/apache2/logs/bbs_access_log_%Y%m%d 86400 480" combined env=!gif-image
上面这段配置的意思就是将上面所有SetEnvIf Request_URI规定的文件名都不统计
同时为了只保留两天的日志可以在crontab中建立个计划任务
30 0 * * * find /usr/local/apache2/logs -name "*access*" -mmin +1440 -exec rm {} \;
评论: