printk - showing in message log but not in terminal for any kernel log level
Clash Royale CLAN TAG#URR8PPP
printk - showing in message log but not in terminal for any kernel log level
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!
6 Answers
6
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.
Can you further elaborate on tail? I've seen it mentioned somewhere else but am unsure how i could call that through c code. Basically, I have created a new system call in linux and use a user application to call the system call. The system call uses printk to output. Is it possible to call the tail function you mention through my application after doing the system call? Thanks again.
– Zach
Jan 31 '10 at 3:05
tail isn't a function, it's a shell command. Try opening another connection (or screen window or however you're doing it), and use 'tail -f /var/log/dmesg'
– Kevin Lacquement
Jan 31 '10 at 3:07
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.
I'm making a new system call in linux and part of it's job will be to output information to the console. I'm using printk to output information and this is where I'm stuck. printk needs to send to the console since I can't access the regular printf
– Zach
Jan 31 '10 at 3:10
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.
/var/log/messages
/proc
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.
Try using
dmesg -wH &
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:
dmesg -wH | grep ERR &
I'm using it to monitor for the "ERROR" messages like
printk(KERN_EMERG "ERROR!n");
that I printk from my driver
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
stackoverflow.com/questions/27903915/…
– Punit Vara
Dec 14 '15 at 13:31