Welcome to the Linux Foundation Forum!

Will Printk() output to the standard terminal?

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?

Comments

  • 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

Categories

Upcoming Training