CentOS 6 Setup Guide

Logs

Logging is a critical aspect of running a server. Log files contain sensitive information, give hints about system errors and can be used in legal disputes - so make sure to thread them carefully.

As an example: If you want to run a web hosting business in Europe, you are required to archive all kind of logs for at least six months.

Tweaking logrotate settings

I do not like how logs are stored and rotated by default, so I set these parameters in the logroate configuration file:

nano /etc/logrotate.conf

#weekly
daily
#rotate 4
rotate 60
compress

This will change weekly rotating to daily, enable compression of rotated log files and keep archived versions for two months (60 days).

Those settings are personal flavoured and in no way "the way to go". I only included them to sensitize you about how logs are rotated on most Linux machines.

Installing Logwatch

Logwatch is a nice utility that can be used to send daily summary emails with all important log entries of the past day. To install, issue:

yum install logwatch

Next, change some options to fit your needs:

nano /etc/logwatch/conf/logwatch.conf

# The default detail level for the report.
# This can either be Low, Med, High or a number.
# Low = 0
# Med = 5
# High = 10
Detail = High

Check /usr/share/logwatch/default.conf/logwatch.conf to see all available options.