Almost 2 years ago I wrote an article about Log rollover for IBM HTTP Server and the WebSphere plugin. The other day I ran into a little tip on making this even fancier by creating a directory per year, per month and if you wished even per day including a symbolic linked file that always refers to the latest log. I found especially the latter a nice addition over the default rotatelogs feature.
What we need for this tip is an extra utility, cronolog, which for most distributions is available in the standard repositories. For RHEL/CentOS the command to install it is:
yum install -y cronolog
Next there’s the line in the httpd.conf. This is an example of what it could look like:
CustomLog "|/sbin/cronolog -S /opt/IBM/IBMHTTPServer/logs/access.log -P /opt/IBM/IBMHTTPServer/logs/access.log.yesterday /opt/IBM/IBMHTTPServer/logs/connections.example.org/access.log/%Y/%m/access-%d.log" combined
This creates a log per day which is saved in a directory per month in a directory per year. Great if you’d like to keep your logs for a long time. What I really like about the solution is the option to automatically create a symbolic link for the current access.log and the one of yesterday, allowing you to have multiple websites with all different logfiles where the access and error logs are all together in one directory named by the website name.