Linux与Windows系统下Cronolog安装配置


前言:

发现WEB服务器上有一个文件一直在不断增长而且速度还很快,一看是日志文件,已经达到一个G了。但又想留下最新的一些日志,不想一下都删除了,但日志文件太大,根本就打不开。其实这时最好用日志轮询,之前这个WEB服务器没有做这个配置,本应该配置WEB服务器时就应该做的。现在配置下也不晚。

1.首先得要软件,下载:http://cronolog.org/download/index.html

Version 1.6.2 released 2002-01-24 (gzip'ed tar file)

Version 1.6.1 released 1999-12-20 (gzip'ed tar file)

Win 32 version (ZIP file)

Version 1.6 released 1999-12-16 (gzip'ed tar file)

Version 1.5b9 released on 4 June 1998 (gzip'ed tar file)

Version 1.4 released 20 December 1996 (gzip'ed tar file)

如果有Windows的要下Win_32_version(ZIP file) Linux习惯用哪种包就用哪种.

2. 在Linux 下安装cronolog

tar zxvf cronolog-1.6.2.tar.gz

cd cronolog-1.6.2

./configure (注意:默认是安装在/usr/local下 cronolog的命令在/usr/local/sbin下,这个要清楚)

make ; make install

3.在Windows下安装cronolog

在Windows下很简单,直接把cronolog.exe解压Copy到apache目录下的bin目录中.

注意:配置都是一样的格式,不过要注意Linux和Windows下斜杠的方向.

Linux下

例:cronolog命令在/usr/local/sbin 下 日志文件在 /usr/local/apache2/logs/下

在FormatLog附近加入两句:

CustomLog "|/usr/local/sbin/cronolog logs/access_%Y%m%d.log" combined

ErrorLog "|/usr/local/sbin/cronolog logs/error_%Y%m%d.log"

Windows下

例:cronolog命令在apache的bin中 日志文件在D:/logs

CustomLog "|bin/cronolog D:/logs/access_%Y%m%d.log" combined

ErrorLog "|bin/cronolog D:/logs/error_%Y%m%d.log"

(注意:斜杠方向都在Linux下是一样的,不跟Windows的习惯一样)

如果有虚拟主机,虚拟主机也要配置,例如:

<VirtualHost *:80>
ServerName www.domain.com
CustomLog "|bin/cronolog.exe D:/logs/access_%Y%m%d.log" combined
ErrorLog "|bin/cronolog.exe D:/logs/error_%Y%m%d.log"
</VirtualHost>

4.重启服务就可以看到生成了一个新的日志文件。

相关文章】

  • 安装cronolog格式化Apache的日志文件
  • linux系统安全要素之一:日志
  • 深入讨论Linux系统日志管理

相关内容