RSS Feed

LogRotation with cronolog


November 26, 2009 by admin

This howto will walk you through how to configure cronolog to rotate apache weblogs.

Install cronolog by running

yum install cronolog

cronolog  can be configured to use all of the following options

Specifier Description
%% a literal % character
%n a new-line character
%t a horizontal tab character
Time fields
%H hour (00..23)
%I hour (01..12)
%p the locale’s AM or PM indicator
%M minute (00..59)
%S second (00..61, which allows for leap seconds)
%X the locale’s time representation (e.g.: “15:12:47”)
%Z time zone (e.g. GMT), or nothing if the time zone cannot be determined
Date fields
%a the locale’s abbreviated weekday name (e.g.: Sun..Sat)
%A the locale’s full weekday name (e.g.: Sunday .. Saturday)
%b the locale’s abbreviated month name (e.g.: Jan .. Dec)
%B the locale’s full month name, (e.g.: January .. December)
%c the locale’s date and time (e.g.: "Sun Dec 15 14:12:47 GMT 1996")
%d day of month (01 .. 31)
%j day of year (001 .. 366)
%m month (01 .. 12)
%U week of the year with Sunday as first day of week (00..53, where week 1 is the week containing the first Sunday of the year)
%W week of the year with Monday as first day of week (00..53, where week 1 is the week containing the first Monday of the year)
%w day of week (0 .. 6, where 0 corresponds to Sunday)
%x locale’s date representation (e.g. today in Britain: “15/12/96”)
%y year without the century (00 .. 99)
%Y year with the century (1970 .. 2038)

For my configuration I’m going to be using year month and day along with the symlink option

Edit you apache config

vi /etc/httpd/conf/httpd.conf

In your virtual host add the following lines

<VirtualHost *:80>

DocumentRoot /var/www/

SuexecUserGroup test1 test1
PHP_Fix_Pathinfo_Enable 1
IPCConnectTimeout 8
IPCCommTimeout 48
ScriptAlias /php/ “/var/www/www.test1/php/”

Options ExecCGI
SetHandler fcgid-script
Order allow,deny
Allow from all

ServerSignature Off

ErrorLog “|/usr/sbin/cronolog –symlink=/var/log/httpd/ /var/log/httpd/”
CustomLog “|/usr/sbin/cronolog –symlink=/var/log/httpd/ /var/log/httpd/” common



You must be logged in to post a comment.