printkに渡すことができるパラメータはたくさんあります。
printk (KERN_INFO "blahahaha");
printk (KERN_EMERG "bababa");
などなど。これらのタグは、syslog.confにあるファシリティレベルと関係がありますか?KERN_EMERGは、「kern.emerg」で指定されたファシリティに印刷されますか?これらの2つのエンティティはどのように結び付けられていますか?
ありがとう
printkに渡すことができるパラメータはたくさんあります。
printk (KERN_INFO "blahahaha");
printk (KERN_EMERG "bababa");
などなど。これらのタグは、syslog.confにあるファシリティレベルと関係がありますか?KERN_EMERGは、「kern.emerg」で指定されたファシリティに印刷されますか?これらの2つのエンティティはどのように結び付けられていますか?
ありがとう
In Order of questions:
Do These Tags have anything to do with the facility levels found in
syslog.conf
?
Yes. The tag is actually a pair, KERN
EMERG
, i.e. KERN
facility, and EMERG
level - they are in upper-case because it's a preprocessor macro, which is by convention written in upper-case. The Linux kernel only cares about the KERN
facility, so other facilities are not defined.
What happens is that all of these printk
commands log to the internal kernel ring buffer. This message may or may not be duplicated to the console (which could be the screen or a serial terminal) based on your kernel settings.
Is KERN_EMERG going to print to facilities specified by "kern.emerg"?
Assuming that you mean log into files that match kern.emerg
, then yes. Examples of entries in syslog.conf
that would match this are kern.*
, kern.emerg
, *.emerg
. A message of the level emerg
is considered fatal, i.e. something seriously bad has happened.
Messages from the kernel at this level may not end up in a syslog file because the error may prevent the writing of data to the hard drive.
How are these two entities tied?
There is a secondary daemon, typically called klogd
. It takes the output from the in-kernel ring buffer and by default passes them on to syslogd
which, records them according to the syslog.conf
file.
So in summary:
printk
puts the message into the ring buffer
. The ring buffer
is read by klogd
which forwards it to syslogd
. Syslogd
records this data into the destination(s) specified by the syslogd.conf
file.