Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does printk() print to?

Just a quick question on printk() function at the kernel level, if I call this where will the message be printed to?(I'm using Ubuntu on i386 arch with the latest kernel download)

can't find it anywhere,

If someone could also point me in the right direction for some sort of manual for the printk() function it would be great!

like image 565
molleman Avatar asked Oct 27 '10 18:10

molleman


People also ask

How does printk work in Linux?

printk is a C function from the Linux kernel interface that prints messages to the kernel log. It accepts a string parameter called the format string, which specifies a method for rendering an arbitrary number of varied data type parameter(s) into a string. The string is then printed to the kernel log.

How do you show printk?

The information which is printed by printk() can only be seen under Alt + Ctrl + F1 ~ F7 console.

What is the difference between printf and printk?

Difference between Printk() and Printf() in Linux :printf() is a C Standard Library function. printk() is used by the kernel to print. To print something from the application layer it uses printf(). The printk() method can be called at any time from almost anywhere in the kernel.


2 Answers

dmesg should display printk messages.

like image 76
Alan Haggai Alavi Avatar answered Oct 16 '22 03:10

Alan Haggai Alavi


printk messages go to the kernel log message buffer, which can be exposed in a variety of ways depending on system configuration. The shell command dmesg will show them, and they should also be being copied to files in /var/log by the syslog daemon. It's possible to get them logged to a serial console or a text-mode virtual terminal, but I don't remember how offhand.

like image 22
zwol Avatar answered Oct 16 '22 01:10

zwol