Linux.com

Home Linux Community Forums Programming and Development Kernel Development Will Printk() output to the standard terminal?

Will Printk() output to the standard terminal?

Link to this post 07 Sep 09

I've put some printk()'s in some of the filesystem files of the linux source tree to try and trace what's going on.
When I run dmesg, I can see a few of my traces, however they aren't showing as I would have expected when I then call the functions again via the terminal.

How can I call some of the system calls and see a modified output?

Link to this post 12 Sep 09

Just gonna answer my own question in-case anyone else is looking for it.

printk() at the default level, outputs to the /var/log/messages file

printk("I am at default level");

The printk level can be defined however to the following levels.
KERN_EMERG
KERN_ALERT
KERN_CRIT
KERN_ERR
KERN_WARNING
KERN_NOTICE
KERN_INFO
KERN_DEBUG

printk(KERN_CRIT "I am a critical level printk");

If it's critical or above, it will print in the terminal as well as /var/log/messages

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board