Apache 的日志默认是直接写入一个独立的 log 文件。如果网站流量大,日志文件很快就会变得很庞大;而 AWStats 等日志分析软件,要求日志文件以天的格式保存。Cronolog 正好可以解决这个问题:它可以对 Apache 的日志按需要进行截断处理(cronolog 也是Apache推荐使用的日志工具之一),是使用 AWStats 进行日志分析的基础。这是 Cronolog 官方网站上的介绍:
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.
如何在 Linux+Apache 环境下安装 cronolog 的文章很多,此文 (https://www.xiaohui.com/dev/server/20070401-apache-cronolog-windows-install.htm) 简单地说明一下 cronolog 在 Windows + Apache 下的安装:
CustomLog "|bin/cronolog.exe logs/access_%Y%m%d.log" combined ErrorLog "|bin/cronolog.exe logs/error_%Y%m%d.log"也可以在虚拟主机配置中使用,例如:
<VirtualHost *:80> ServerName www.xiaohui.com CustomLog "|bin/cronolog.exe logs/xiaohui.com/access_%Y%m%d.log" combined ErrorLog "|bin/cronolog.exe logs/xiaohui.com/error_%Y%m%d.log" </VirtualHost>