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/messagesanddmesgwill show the same logs (in different format) aftersyslogdand/orklogdstarted? – xanpeng Apr 06 '12 at 04:56klogdis running,dmesgwill 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/messageswill retain logs according to howlogrotateis configured and include timestamping (which will be slightly inaccurate for initial boot messages becausedmesgdoesn't have them, so the timeklogdstarted is used for all messages read from the kernel buffer). – geekosaur Apr 06 '12 at 05:18dmesgonly contains messages from the kernel,/var/log/messagesusually contains logs from applications as well. – Gilles 'SO- stop being evil' Apr 06 '12 at 23:34