cronolog使用

tech2024-04-08  13

cronolog使用

I have been experimenting with Cronolog, developed by Andrew Ford, who also authored the Apache Pocket Reference, published by O’Reilly and Associates.

我一直在尝试由安德鲁·福特(Andrew Ford)开发的Cronolog ,他还撰写了由O'Reilly and Associates出版的Apache Pocket Reference。

I elected to work with cronolog based on a recommendation from a peer and the fact that the log files for the site in question were unmanageable in size. You may remember it being briefly mentioned at the end of my column on Apache web logs.

我根据同行的建议选择了cronolog,并且该站点的日志文件的大小无法控制。 您可能还记得我在Apache Web日志专栏的末尾简要提到了它。

This handy program allows for logs to be broken down by day, month and year. I chose a middle ground and have them set to rotate to new logs on the first of each month.

这个方便的程序允许按日,月和年细分日志。 我选择了一个中间立场,并设置为在每个月的第一天轮换使用新日志。

Installation is very easy. After downloading and unpacking — simply use ./configure and make to build the executable. You can then copy src/cronolog to where you want to call it from. I used /usr/local/sbin/cronolog.

安装非常容易。 下载并解压缩后,只需使用./configure并制作即可生成可执行文件。 然后,您可以将src / cronolog复制到您要从其调用的位置。 我使用了/ usr / local / sbin / cronolog。

Usage is fairly straightforward as well. I noted a snippet from my httpd.conf below to show how it integrates into the Apache log config inside of virtual servers.

用法也相当简单。 我在下面的httpd.conf中记下了一个片段,以显示它如何集成到虚拟服务器内部的Apache日志配置中。

… … … CustomLog “|/usr/local/sbin/cronolog /home/domains/mydomain.com/logs/%Y/%m/access_log” combined ErrorLog “|/usr/local/sbin/cronolog /home/domains/mydomain.com/logs/%Y/%m/error_log” … …

………CustomLog“ | / usr / local / sbin / cronolog /home/domains/mydomain.com/logs/%Y/%m/access_log”与ErrorLog“ | / usr / local / sbin / cronolog / home / domains / mydomain.com/logs/%Y/%m/error_log”…………

The cronolog program is called and reads log message input and manages the log file, also conveniently creating a folder hierarchy in your logs folder by month and year as it creates each month’s new log file.

cronolog程序被调用并读取日志消息输入并管理日志文件,还可以方便地在月份文件夹中按月和年份在日志文件夹中创建文件夹层次结构,因为它创建了每月的新日志文件。

Now my logs folder looks like this:

现在我的日志文件夹如下所示:

logs/ 2004/

日志/ 2004 /

Within the 2004 directory I see 07 and 08 directories for July and August, each that contain an access_log and error_log for the month.

在2004目录中,我看到7月和8月的07和08目录,每个目录都包含一个月的access_log和error_log。

A final note — the Cronolog credits Klaus Mueller with creating a Windows binary for cronolog to run on Windows systems. The download is here.

最后一点-Cronolog归功于Klaus Mueller为cronolog创建了可在Windows系统上运行的Windows二进制文件。 下载在这里 。

翻译自: https://www.sitepoint.com/logging-with-cronolog/

cronolog使用

最新回复(0)