modify kernel logging

By default Centos 4.5 doesnt log kernel messages to the console.

In order to enable kernel logging in Centos 4.5 (In oder distros the process is very similar, though) to log to the console and to a file we will proceed as follows:

Change kernel logging:

Modify:

cp /etc/syslog.conf /etc/syslog.conf.`date +%Y%b%g`
vi /etc/syslog.conf

Change:
#kern.* /dev/console

To:
kern.* /dev/console
kern.* /var/log/kernel.log

Restart syslogd and check that the new log file has been created

/etc/init.d/syslog restart
ls -l /var/log/kernel.log

Add this new log to log rotate (You don't want it to grow uncontrollably do you?)

mkdir /root/backup
cp /etc/logrotate.d/syslog /root/backup/syslog.`date +%Y%b%g`
vi /etc/logrotate.d/syslog

Change:
/var/log/messages /var/log/secure /var/log/maillog /var/log/spooler /var/log/boot.log /var/log/cron {

To:
/var/log/kernel.log /var/log/messages /var/log/secure /var/log/maillog /var/log/spooler /var/log/boot.log /var/log/cron {

Logging to the console could help you in case you have hosted servers on a remote location.
If one of this servers crashes due to a hardware issue, people at the hosting location will still be able to see if there are relevant messages on the physical console.
There are of course other methods for debugging crashes such as redirecting consoles messages to other machine through the serial port or using other tools such as netdump, diskdump… etc

back to Linux documents

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License