views:

71

answers:

4

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!

+2  A: 

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.

caskey
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
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'
lacqui
A: 

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.

Steven Schlansker
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
A: 

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.

Paul Betts
A: 

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.

Nikolai N Fetissov