What’s the difference of dmesg output and /var/log/messages

dmesgkernellogs

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.

Best Answer

dmesg prints the contents of the ring buffer. This information is also sent in real time to syslogd or klogd, when they are running, and ends up in /var/log/messages; when dmesg is most useful is in capturing boot-time messages from before syslogd and/or klogd started, so that they will be properly logged.

Related Question