AFAIK dmesg
shows information about kernel and kernel modules, and /var/log/messages
also shows information produced by kernel and modules.
So what's the difference? Does /var/log/messages
⊂ output of dmesg
?
More Info that may be helpful:
- There is a kernel ring buffer, which I think is the very and only place to store kernel log data.
- Article "Kernel logging: APIs and implementation" on IBM DeveloperWorks described APIs and the bird-view picture.
/var/log/messages
anddmesg
will show the same logs (in different format) aftersyslogd
and/orklogd
started? – xanpeng Apr 06 '12 at 04:56klogd
is running,dmesg
will show only the most recent kernel messages (because the ring buffer is a fixed size and so can only hold so much), without timestamps or other information, while/var/log/messages
will retain logs according to howlogrotate
is configured and include timestamping (which will be slightly inaccurate for initial boot messages becausedmesg
doesn't have them, so the timeklogd
started is used for all messages read from the kernel buffer). – geekosaur Apr 06 '12 at 05:18dmesg
only contains messages from the kernel,/var/log/messages
usually contains logs from applications as well. – Gilles 'SO- stop being evil' Apr 06 '12 at 23:34