Continuing in our series on logging, with a quick look at cronolog which is another powerful logging tool you can employ on your systems. With cronolog you can organize your logs into a chronological hierarchy of files. An interesting twist is the symbolic linking of the current log file back to a specified location which can be useful in working with log analyzers like Webalizer and AccessWatch.
Once again it is we will define a custom log format but you can use a predefined one if that suits your needs. Remember if you intend to use this format on multiple virtual hosts then you should consider defining it either in the main httpd.conf or a config file that is included prior to the vhost config.
LogFormat "%h %l %u %t "%r" %>s %b" SpecialLog
In your vhost config you will want to add the apache CustomLog directive including the pipe into cronolog. On my FreeBSD based system cronolog lives in /usr/local/sbin/cronolog. I have provided the –symlink command line parameter telling cronolog to link the current file to that path. In addition cronolog will organize the log files in a year/month hierarchy as a result of the parameter /web/jafdip.com/logs/%Y/%m/%d-access_log with the storing all of the daily logs in their own discreet files.
I have shortened the example for readability.
CustomLog "|cronolog --symlink=/web/jafdip.com/logs/access_log /web/jafdip.com/logs/%Y/%m/%d-access_log" SpecialLog
One thing to keep in mind is that you will want to take care with log processing so that the file is process prior to rotation. This is basically the same issue we had with rotatelog in the previous article. depending upon how much traffic you get and how long it takes to process the web statistics we could run into some issues if the files were rotated too early or even worse during the analysis. Rotating the files after the analysis has complete still leave open the possibility of missing some beats so bear that in mind as well. Depending upon how busy your site is will determine how critical your statistics might need to be.
Unfortunately, there is no partial stage rotation at this point which would be handy with either of these solutions for a busy site. Something that triggers a rotation to a midway file name then launching the analyzer and finally completes the rotation upon the completion of the analysis. In any event it is nice to know that we have options for our logging pleasure.
Leave a Reply