I'm doing some kernel modification and am trying to get printk to output information back to the console. I pass any kernel log level with it and do not properly get any response back on the console for even the highest log levels.
I checked and the current log configuration for printk is 4 4 1 7.
It prints properly each time to logs. I can use dmesg | less and see it appended to the log. But I can't return it to console properly using printk.
I'm not sure that it matters but I use SSH to connect to a remote machine where the modified kernel exists.
I've tried SSH from gnome-terminal and from putty in Windows. Neither change a thing. Still shows printk in the server's logs, but not on my console.
Any way to get it to the console? What could be going wrong given that I've tried every log level and none work? THANKS!
Just to make sure, you are in init level 3 (text mode) aren't you? If you have run startx and are working in graphical mode, you will not see stuff on the terminal.
I believe that prink only logs to the physical consoles, if you want to monitor the kernel output via arbitrary ttys, then you will need to use tail to monitor a file being written to by syslog, or an application such as xconsole which specifically monitors /dev/console for messages.
Try using
to force all your kernel messages, that are printed to dmesg (and also the virtual terminals like Ctrl+Alt+F1 , depending on your /proc/sys/kernel/printk log level and a level of your message), to also appear at your SSH or GUI console: Konsole, Terminal or whatever you are using! And, if you need to monitor only for the specific messages:
I'm using it to monitor for the "ERROR" messages like
that I printk from my driver
I believe some variants of syslog support this without doing kernel modifications, perhaps by logging to /dev/console. Is there any particular reason you're trying to modify the kernel to do this? I'd guess there's an easier way.
Some distros patch out printk so it doesn't show up (Red Hat was first, Ubuntu does it too afaik) - you're probably hitting this.
If it's for debugging - just tail the
/var/log/messages
. If you need stable output from your kernel module - create a char device or a file under/proc
and have userland process read from there.