Rss & SiteMap

大家论坛-大家学习网论坛 http://bbs.topsage.com

大家学习网是致力于提供在线学习交流、相关资讯和服务的网络媒体平台,目前已经拥有强大的英语、计算机、财会、公务员、各类资格考试,及软件,电子书,教程下载 等频道。建站以来,大家学习网奇迹般的保持强劲的增长势头,以出色的品牌形象与公信力赢得越来越多大家网友的信任与支持, 正朝着中国最大的学习门户方向迈进
共1 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:Apache日志分割工具cronolog

1楼
Kernel 发表于:2008-7-2 14:55:00
为了分析apache日志,我们需要定时将日志文件分割出来,这样类似webalizer等日志分析程序
才能非常方便的统计数据。apache默认配置的rotatelogs只能是按照一定时间或者一定文件大小来分割,而我们通常需要得到的是一整天或者一个
小时的日志数据,为了解决这个问题,我采用了第三方的一个程序cronolog

http://www.cronolog.org下载源码包,在root用户下执行下面的指令

./tar -xzvf cronolog-1.6.2.tar.gz
cd cronolog-1.6.2
./configure
make
make install

正常编译以后会在默认目录/usr/local/sbin下有一个cronolog文件
在任何目录测试执行cronolog,应该显示出cronolog的帮助内容

usage: cronolog [OPTIONS] logfile-spec

   -H NAME,   --hardlink=NAME maintain a hard link from NAME to current log
   -S NAME,   --symlink=NAME  maintain a symbolic link from NAME to current log
   -P NAME,   --prev-symlink=NAME  maintain a symbolic link from NAME to previous log
   -l NAME,   --link=NAME     same as -S/--symlink
   -h,        --help          print this help, then exit
   -p PERIOD, --period=PERIOD set the rotation period explicitly
   -d DELAY,  --delay=DELAY   set the rotation period delay
   -o,        --once-only     create single output log from template (not rotated)
   -x FILE,   --debug=FILE    write debug messages to FILE
                              ( or to standard error if FILE is "-")
   -a,        --american         American date formats
   -e,        --european         European date formats (default)
   -s,    --start-time=TIME   starting time
   -z TZ, --time-zone=TZ      use TZ for timezone
   -V,      --version         print version number, then exit

至此,cronolog部分安装完毕,转到apache的配置文件,在原有日志设置的地方修改成下面的样子

CustomLog "|/usr/local/sbin/cronolog /opt/logs/access_log.%Y-%m-%d" combined

当然你需要确认这些路径是否符合你的系统设置,上面是按照每天进行日志翻滚,如果需要其他的翻滚设置,可以参考cronolog的帮助文件。

重新启动apache后,可以看到日志已经产生了新的带时间的版本
共1 条记录, 每页显示 10 条, 页签: [1]


Copyright © 2002 - 2007 topsage.Com

京ICP备06071611号


百度大联盟认证绿色会员

Powered By Dvbbs Version 8.2.0
Processed in .03516 s, 2 queries.