设为首页收藏本站

LinuxTone | 运维专家网论坛 - 最棒的Linux运维与开源架构技术交流社区!

 找回密码
 注册

用新浪微博连接

一步搞定

QQ登录

只需一步,快速开始

查看: 2950|回复: 3

[Apache] cronolog 割断分析apache日志 [复制链接]

初级会员

linuxtone社区欢迎您

Rank: 2

签到
0
注册时间
2008-5-25
最后登录
2011-11-24
在线时间
125 小时
阅读权限
20
积分
136
帖子
50
主题
34
精华
1
UID
4
发表于 2008-5-27 21:11:24 |显示全部楼层
使用cronolog可以格式化日志文件的格式,比如按时间分割,易于管理和分析。
cronolog的安装配置非常简单,简要说明如下:
1.下载软件
http://cronolog.org/download/index.html
2.解压缩
gzip -d cronolog-1.6.2.tar.gz
tar xf cronolog-1.6.2.tar
2.进入相应的目录 ./configure
3.make
4.make install
5.修改apache配置文件

以下是我的安装日志,供大家参考:

[root@linuxsir1987 src]# wget http://cronolog.org/download/cronolog-1.6.2.tar.gz
--08:05:12--  http://cronolog.org/download/cronolog-1.6.2.tar.gz
           => `cronolog-1.6.2.tar.gz'
Resolving cronolog.org... done.
Connecting to cronolog.org[217.160.212.212]:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 133,591 [application/x-gzip]

100%[==================================>] 133,591       26.23K/s    ETA 00:00

08:05:19 (26.23 KB/s) - `cronolog-1.6.2.tar.gz' saved [133591/133591]
[root@linuxsir1987 src]# gzip -d cronolog-1.6.2.tar.gz
[root@linuxsir1987 src]# tar xf cronolog-1.6.2.tar
[root@linuxsir1987 src]# cd cronolog-1.6.2
[root@linuxsir1987 cronolog-1.6.2]# ls
aclocal.m4  config.cache   configure     cronolog.spec  install-sh  Makefile.am  mkinstalldirs  src
AUTHORS     config.log     configure.in  doc            lib         Makefile.in  NEWS           testsuite
ChangeLog   config.status  COPYING       INSTALL        Makefile    missing      README         TODO
[root@linuxsir1987 cronolog-1.6.2]# ./configure  
loading cache ./config.cache
checking for a BSD compatible install... (cached) /usr/bin/install -c
checking whether build environment is sane... yes
checking whether make sets ${MAKE}... (cached) yes
checking for working aclocal... found
checking for working autoconf... found
checking for working automake... found
checking for working autoheader... found
checking for working makeinfo... found
checking for gcc... (cached) gcc
checking whether the C compiler (gcc  ) works... yes
checking whether the C compiler (gcc  ) is a cross-compiler... no
checking whether we are using GNU C... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for a BSD compatible install... /usr/bin/install -c
checking whether ln -s works... (cached) yes
checking for ranlib... (cached) ranlib
checking for perl... (cached) /usr/bin/perl
checking how to run the C preprocessor... (cached) gcc -E
checking for ANSI C header files... (cached) yes
checking whether stat file-mode macros are broken... (cached) no
checking whether time.h and sys/time.h may both be included... (cached) yes
checking whether struct tm is in sys/time.h or time.h... (cached) time.h
checking for tm_zone in struct tm... (cached) yes
checking for fcntl.h... (cached) yes
checking for limits.h... (cached) yes
checking for unistd.h... (cached) yes
checking for working const... (cached) yes
checking for size_t... (cached) yes
checking whether struct tm is in sys/time.h or time.h... (cached) time.h
checking for strftime... (cached) yes
checking for vprintf... (cached) yes
checking for mkdir... (cached) yes
checking for mktime... (cached) yes
checking for putenv... (cached) yes
checking for strptime... (cached) yes
checking for localtime_r... (cached) yes
creating ./config.status
creating Makefile
creating lib/Makefile
creating src/Makefile
creating doc/Makefile
creating testsuite/Makefile
creating src/cronosplit
[root@eygle cronolog-1.6.2]# make
Making all in lib
make[1]: Entering directory `/opt/src/cronolog-1.6.2/lib'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/opt/src/cronolog-1.6.2/lib'
Making all in src
make[1]: Entering directory `/opt/src/cronolog-1.6.2/src'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/opt/src/cronolog-1.6.2/src'
Making all in doc
make[1]: Entering directory `/opt/src/cronolog-1.6.2/doc'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/opt/src/cronolog-1.6.2/doc'
Making all in testsuite
make[1]: Entering directory `/opt/src/cronolog-1.6.2/testsuite'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/opt/src/cronolog-1.6.2/testsuite'
make[1]: Entering directory `/opt/src/cronolog-1.6.2'
make[1]: Nothing to be done for `all-am'.
make[1]: Leaving directory `/opt/src/cronolog-1.6.2'
[root@eygle cronolog-1.6.2]# make install
Making install in lib
make[1]: Entering directory `/opt/src/cronolog-1.6.2/lib'
make[2]: Entering directory `/opt/src/cronolog-1.6.2/lib'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/opt/src/cronolog-1.6.2/lib'
make[1]: Leaving directory `/opt/src/cronolog-1.6.2/lib'
Making install in src
make[1]: Entering directory `/opt/src/cronolog-1.6.2/src'
make[2]: Entering directory `/opt/src/cronolog-1.6.2/src'
/bin/sh ../mkinstalldirs /usr/local/sbin
  /usr/bin/install -c  cronolog /usr/local/sbin/cronolog
/bin/sh ../mkinstalldirs /usr/local/sbin
/usr/bin/install -c  cronosplit /usr/local/sbin/cronosplit
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/opt/src/cronolog-1.6.2/src'
make[1]: Leaving directory `/opt/src/cronolog-1.6.2/src'
Making install in doc
make[1]: Entering directory `/opt/src/cronolog-1.6.2/doc'
make[2]: Entering directory `/opt/src/cronolog-1.6.2/doc'
make[2]: Nothing to be done for `install-exec-am'.
/bin/sh ../mkinstalldirs /usr/local/info
/usr/bin/install -c -m 644 ./cronolog.info /usr/local/info/cronolog.info
install-info --info-dir=/usr/local/info /usr/local/info/cronolog.info
make  install-man1
make[3]: Entering directory `/opt/src/cronolog-1.6.2/doc'
/bin/sh ../mkinstalldirs /usr/local/man/man1
/usr/bin/install -c -m 644 ./cronolog.1m /usr/local/man/man1/cronolog.1m
/usr/bin/install -c -m 644 ./cronosplit.1m /usr/local/man/man1/cronosplit.1m
make[3]: Leaving directory `/opt/src/cronolog-1.6.2/doc'
make[2]: Leaving directory `/opt/src/cronolog-1.6.2/doc'
make[1]: Leaving directory `/opt/src/cronolog-1.6.2/doc'
Making install in testsuite
make[1]: Entering directory `/opt/src/cronolog-1.6.2/testsuite'
make[2]: Entering directory `/opt/src/cronolog-1.6.2/testsuite'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/opt/src/cronolog-1.6.2/testsuite'
make[1]: Leaving directory `/opt/src/cronolog-1.6.2/testsuite'
make[1]: Entering directory `/opt/src/cronolog-1.6.2'
make[2]: Entering directory `/opt/src/cronolog-1.6.2'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/opt/src/cronolog-1.6.2'
make[1]: Leaving directory `/opt/src/cronolog-1.6.2'
[root@linuxsir1987 cronolog-1.6.2]# which cronolog
/usr/local/sbin/cronolog

安装完成以后需要对apache进行适当配置,修改httpd.conf文件,主要注意以下几点:
1.自定义日志格式
CustomLog "|/usr/local/sbin/cronolog /opt/app/apache2/logs/access_log.%Y%m%d" combined
2.如果存在多个虚拟站点
可以考虑在VirtualHost进行相应设置


    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot /www/docs/dummy-host.example.com
    ServerName dummy-host.example.com
    ErrorLog logs/dummy-host.example.com-error_log
    CustomLog logs/dummy-host.example.com-access_log common

我的www.test.com存在多个子站点,但是都使用了同一个日志文件
配置后生成日志文件的效果:

[root@linuxsir1987 logs]# ls -l access_log.2008527
-rw-r--r--    1 root     root       110425 Dec 26 09:10 access_log.20080527
一直从事linux系统维护于管理工作,有可能会在明年踏入php开发,请大家多多指教。

Rank: 8Rank: 8

注册时间
2010-1-19
最后登录
2012-5-22
在线时间
67 小时
阅读权限
90
积分
4152
帖子
83
主题
12
精华
0
UID
7631
发表于 2010-1-26 10:17:11 |显示全部楼层
谢谢楼主分享!

使用道具 举报

LT管理团队

守住每一天

Rank: 9Rank: 9Rank: 9

注册时间
2008-5-30
最后登录
2012-5-23
在线时间
641 小时
阅读权限
200
积分
16234
帖子
1273
主题
176
精华
11
UID
31
发表于 2010-1-26 15:26:51 |显示全部楼层
过2G日志。还是用bate版本吧
<-sina_sign,1054764633,7->

使用道具 举报

Rank: 6Rank: 6

注册时间
2010-8-18
最后登录
2012-5-17
在线时间
42 小时
阅读权限
70
积分
1406
帖子
49
主题
0
精华
0
UID
10139
发表于 2010-9-6 10:07:58 |显示全部楼层
这个很好用,哈哈!

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

IT运维专家网感谢红之盟网络提供带宽支持

合作联系: QQ:67888954/MSN:cnseek@msn.com/mail:netseek@linuxtone.org

Archiver|手机版|感谢所有关心和支持过LinuxTone的朋友们 转载本站内容请注明原作者名及出处 ( 京ICP备08103151 )   |

GMT+8, 2012-5-23 11:29 , Processed in 0.162562 second(s), 12 queries , Memcache On.

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部