手机版
你好,游客 登录 注册
背景:
阅读新闻

Linux 日志切割工具cronolog详解

[日期:2014-01-05] 来源:Linux社区  作者:freeloda [字体: ]

一、前言
二、cronolog 简介
三、cronolog 特点
四、cronolog 安装
五、cronolog 使用
六、cronolog 总结
注,操作系统 CentOS 6.4 x86_64,软件版本 cronolog 1.6.2,软件下载 http://cronolog.org/download/index.html。

一、前言
大家都知道apache服务器,默认日志文件是不分割的,一个整文件既不易于管理,也不易于分析统计。本博文主要讲解Web服务器日志切割工具cronolog,下面我们就来详细的讲解一下。

二、cronolog 简介
Welcome to cronolog.org, the home of the cronolog web log rotation program.cronolog is a simple filter program that reads log file entries from standard input and writes each entry to the output file specified by a filename template and the current date and time. When the expanded filename changes, the current file is closed and a new one opened. cronolog is intended to be used in conjunction with a Web server, such as Apache, to split the access log into daily or monthly logs.

cronolog 是一个简单的过滤程序,读取日志文件条目从标准输入和输出的每个条目并写入指定的日志文件的文件名模板和当前的日期和时间。当扩展文件名的变化,目前的文件是关闭,新开辟的。cronolog 旨在和一个Web服务器一起使用,如Apache,分割访问日志为每天或每月的日志。

三、cronolog 特点
cronolog主要和Web服务器配置使用,特别是Apache服务器,Apache 默认日志文件是不分割的,一个整文件既不易于管理,也不易于分析统计。安装cronolog后,可以将日志文件按时间分割,易于管理和分析。下面是与Apache配置的一些指令:
12 TransferLog "|/usr/sbin/cronolog /web/logs/%Y/%m/%d/access.log"
ErrorLog    "|/usr/sbin/cronolog /web/logs/%Y/%m/%d/errors.log"

下面是具体案例,

/web/logs/2002/12/31/access.log/web/logs/2002/12/31/errors.log
/web/logs/2003/01/01/access.log/web/logs/2003/01/01/errors.log

四、cronolog 安装

1.安装yum源
[root@node6 src]# yum install -y wget vim
[root@node6 src]# wget http://ftp.sjtu.edu.cn/Fedora/epel/6/i386/epel-release-6-8.noarch.rpm
[root@node6 src]# rpm -ivh epel-release-6-8.noarch.rpm
warning: epel-release-6-8.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing...                ########################################### [100%]
  1:epel-release          ########################################### [100%]

2.安装ntp
[root@node6 src]# yum install -y ntp

3.时间同步
[root@node6 src]# ntpdate 202.120.2.101
28 Dec 17:59:17 ntpdate[1413]: step time server 202.120.2.101 offset -25666.776448 sec

4.安装cronolog
(1).直接用yum安装
[root@node6 src]# yum install -y cronolog httpd

(2).源码安装 
[root@node6 src]# wget http://cronolog.org/download/cronolog-1.6.2.tar.gz
[root@node6 src]# tar xf cronolog-1.6.2.tar.gz
[root@node6 src]# cd cronolog-1.6.2
[root@node6 cronolog-1.6.2]# ./configure
[root@node6 cronolog-1.6.2]# make && make install
[root@localhost ~]# which cronolog
/usr/local/sbin/cronolog

好了,到这里我们的cronolog就安装完成了,下面我们来说一下cronolog如何使用。


相关阅读

Ubuntu 安装cronolog工具遇到的问题及解决方法  http://www.linuxidc.com/Linux/2010-07/27152.htm

利用cronolog自动切割Apache的日志 http://www.linuxidc.com/Linux/2011-11/47758.htm

用cronolog分割Nginx日志 http://www.linuxidc.com/Linux/2012-11/75154.htm

linux
相关资讯       Linux日志  Cronolog 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款