1.日志分割(请参考)
安装cronolog
http://bbs.linuxtone.org/thread-93-1-1.html
2.过滤掉无需记录的日志
#在httpd.conf 的
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
后面加入如下:
- # filter the localhost visit
- SetEnvIf Remote_Addr "127\.0\.0\.1" dontlog
- # filter some special directories
- SetEnvIf Request_URI "^ZendPlatform.*$" dontlog
- SetEnvIf Request_URI \.healthcheck\.html$ dontlog
- SetEnvIf Remote_Addr "::1" dontlog
- SetEnvIf Request_URI "\.getPing.php$" dontlog
- SetEnvIf Request_URI "^/error\.html$" dontlog
- SetEnvIf Request_URI "\.gif$" dontlog
- SetEnvIf Request_URI "\.jpg$" dontlog
- SetEnvIf Request_URI "\.css$" dontlog
复制代码其它根据自己的需要做一些调整。
另一种日志不记录图片的方法:
- <FilesMatch "\.(ico|gif|jpg|swf)">
- SetEnv dontlog 1
- </FilesMatch>
- CustomLog logs/access_log combined env=!dontlog
复制代码3.日志处理
压缩每天的日志
30 3 * * * /usr/bin/gzip -f /data/logs/access_www.linuxtone.org.`date -d yesterday +%Y%m%d.log
删除前三天的日志
30 5 * * */usr/bin/find /data/logs/ -name access_*.gz -mtime +3 |xargs -r /bin/rm -f
4.利用awstats分析日志
http://bbs.linuxtone.org/thread-56-1-1.html