RSS

Rotating Apache logs with logrotate

27 Feb

It’s pretty easy to set this up on Linux as most distros come with rotatelog functionality.

All I had to do was to create a file /etc/logrotate.d/apache2 with this content:

/usr/local/apache/domlogs/www3.serbiancafe.com.short {
daily
missingok
rotate 5
ifempty
copytruncate
olddir /usr/local/apache/domlogs/oldlogs
}

/usr/local/apache/logs/*_log {
rotate 3
size 100M
copytruncate
}

If plain English:
First log is rotated on a daily basis regardless if the log is there or empty. Last 5 logs are kept in “olddir” directory. And, you don’t have to restart Apache when you use copytruncate directive.

Second group defines a rotation for all files ending with “_log”. They rotate three files when their size is over 100M.

More options can be found in logrotate man page

Advertisements
 
Leave a comment

Posted by on February 27, 2009 in Uncategorized

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: