[wplug] using printk

Ingimarson, Darin dingimarson at Quantapoint.com
Wed Nov 13 10:34:37 EST 2002


Henry,

I am assuming you are hacking kernel code...

printk() will print to /var/log/messages or the console depending 
upon what the settings are in your syslog config file. If you want
to force it to print out, you can specify the loglevel as critical 
in your printk call as folows:

    printk(KERN_CRIT, "Something important happened here...\n");

This should make the message appear both on the console and in the
/var/log/messages file.

There are eight possible loglevels as follows:
KERN_EMERG
KERN_ALERT
KERN_CRIT
KERN_ERR
KERN_WARNING
KERN_NOTICE
KERN_INFO
KERN_DEBUG

A printk() with no specified priority defaults to DEFAULT_MESSAGE_LOGLEVEL

You can modify the console loglevel using the proc filesystem as follows:

# echo 8 > /proc/sys/kernel/printk

This will cause ALL kernel messages to appear at the console (note that 
you will need an actual CONSOLE to print this out on, not some xterm
window).

Check your system to see if both klogd and syslogd are running; the
kernel messages from the modules should be logged to /var/log/messages
based upon the configuration of these. If klogd is not running, the 
messages will NOT reach user space unless /proc/kmsg is being read by
soemthing.


> -----Original Message-----
> From: Henry Umansky [mailto:hmust2+ at pitt.edu]
> Sent: Wednesday, November 13, 2002 10:21 AM
> To: wplug at wplug.org
> Subject: [wplug] using printk
> 
> 
> When using printk("string") in a kernel module, where does it 
> print to??  I 
> thought it would print to /var/log/messages but it is not there.
> 
> -Henry
> _______________________________________________
> wplug mailing list
> wplug at wplug.org
> http://www.wplug.org/mailman/listinfo/wplug
> 



More information about the wplug mailing list