Logging with Cronolog

Share this article

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

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.

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.

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.





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”


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.

Now my logs folder looks like this:

logs/
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.

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

Frequently Asked Questions about Cronolog

What is the main function of Cronolog?

Cronolog is a simple, yet powerful utility that helps manage log files. It reads log messages from its input and writes them to a set of output files, the names of which are constructed using template and the current date and time. The main function of Cronolog is to automatically rotate log files without having to shut down and restart the logging process. This makes it an invaluable tool for system administrators managing large systems where logs can quickly become unmanageable.

How does Cronolog differ from other log file management tools?

Unlike other log file management tools, Cronolog is designed to be as simple and lightweight as possible. It doesn’t require any complex configuration or setup. All you need to do is specify the log file template and Cronolog will handle the rest. It’s also highly flexible, allowing you to specify exactly how and when your log files should be rotated.

Can Cronolog handle large log files?

Yes, Cronolog is designed to handle large log files efficiently. It does this by rotating log files based on time rather than size. This means that even if your log files grow very large, Cronolog can still rotate them without any performance impact. This makes it an ideal solution for managing log files on high-traffic servers.

How do I install Cronolog on my system?

Installing Cronolog is straightforward. You can download the source code from the official website and compile it yourself, or you can install it from your distribution’s package manager if it’s available. Once installed, you can start using Cronolog immediately without any additional setup.

How do I use Cronolog with my existing logging setup?

Cronolog is designed to work seamlessly with your existing logging setup. You simply pipe your log output into Cronolog and it will handle the rest. This means you don’t need to modify your existing logging processes or scripts to use Cronolog.

Can I use Cronolog to rotate logs from multiple applications?

Yes, Cronolog can handle logs from multiple applications simultaneously. Each application can have its own log file template, allowing you to organize your logs in a way that makes sense for your setup.

What platforms does Cronolog support?

Cronolog is a cross-platform tool. It’s written in C, which means it can be compiled and run on any system that has a C compiler. This includes all major Linux distributions, BSD, macOS, and even Windows with the right tools.

Can I customize how Cronolog rotates my log files?

Yes, Cronolog is highly customizable. You can specify exactly how and when your log files should be rotated using the log file template. This allows you to tailor Cronolog to your specific needs.

Is Cronolog actively maintained?

Cronolog is an open-source project, which means it’s maintained by a community of volunteers. While it may not have the same level of active development as some commercial tools, it’s still a reliable and robust solution for log file management.

Where can I find more information about Cronolog?

You can find more information about Cronolog on its official website. There you’ll find the full documentation, as well as a community forum where you can ask questions and share your experiences with other Cronolog users.

Blane WarreneBlane Warrene
View Author
Share this article
Read Next
Get the freshest news and resources for developers, designers and digital creators in your inbox each week
Loading form