Tips記事
» 2001年01月24日 00時00分 UPDATE

カーネルメッセージをsyslogに記録させたい

[木田佳克,ITmedia]

 dmesgコマンドなどで確認できるカーネルメッセージは,マシンを再起動すると消えてしまう。以前のエラーログなどを確認したい場合には,syslogに記録させておくのがよいだろう。次の行を,/etc/syslog.confに加えればよい。

kern.warn /var/warnings

※Red Hat Linux 6.2の標準設定
/etc/syslog.conf

# Log all kernel messages to the console.
# Logging much else clutters up the screen.
#kern.* /dev/console

# Log anything (except mail) of level info or higher.
# Don't log private authentication messages!
*.info;mail.none;news.none;authpriv.none /var/log
/messages

# The authpriv file has restricted access.
authpriv.* /var/log/secure

# Log all the mail messages in one place. mail.* /var/log/maillog
#mail.info /var/adm/wrappers

# Everybody gets emergency messages, plus log them on another
# machine.
*.emerg *

# Save mail and news errors of level err and higher in a
# special file.
uucp,news.crit /var/log/spooler

# Save boot messages also to boot.log
local7.* /var/log/boot.log

#
# INN
#
news.=crit /var/log/news/news.crit
news.=err /var/log/news/news.err
news.notice /var/log/news/news.notice

 ほかにも,メッセージ内容によって記録するログファイルを分けたり,Eメールで通知することも可能だ。

例1:kern.*      /var/kernel
例2:kern.crit     /dev/console
例3:kern.info;kern.!err /var/adm/kernel-info

 syslog.confを編集したら,忘れずにsyslogdデーモンを再起動しておこう。

# /etc/rc.d/init.d/syslog restart
Shutting down kernel logger:    [ OK ]
Shutting down system logger:    [ OK ]
Starting system logger:       [ OK ]
Starting kernel logger:       [ OK ]

Copyright © ITmedia, Inc. All Rights Reserved.

注目のテーマ