(Edit: Additional info is here too: Description of kernel.printk values)
You can use the sysctl command/system to alter the kernel printk settings as desired.
sysctl -w kernel.printk="4 4 1 7"
would set the printk settings to 'default' values, while
sysctl -w kernel.printk="3 4 1 3"
would prevent low level messages from being output to the console.
will show you your current settings.
From the linux documentation (kernel docs):
The four values in printk denote: console_loglevel, default_message_loglevel,
minimum_console_loglevel and default_console_loglevel respectively.
These values influence printk() behavior when printing or logging
error messages. See 'man 2 syslog' for more info on the different
- console_loglevel: messages with a higher priority than this will be printed to the console
- default_message_loglevel: messages without an explicit priority will be printed with this priority
- minimum_console_loglevel: minimum (highest) value to which console_loglevel can be set
- default_console_loglevel: default value for console_loglevel
You will usually need to be root, or have sudo privileges to write (-w) new values using sysctl. You could also echo values into /proc/sys/kernel/printk, need to be root(ish) for that too.
My Monkey Debugging Assistant just reminded me that there is another way to obtain the kernel printk messages which could be useful.
It is possible to request that syslog/rsyslog/whateverlog daemon send the kernel output to a particular file, pipe or socket, to be read by a program of your choosing, parsed, saved or discarded as appropriate.
My rsyslog.conf shows that all kern.* level messages are sent to /var/log/kern.log, you could easily listen to that file and obtain any messages you desired.
It's also possible to define your own facility type and have rsyslog send those to someplace special. Even selectively sending kern.warn or kern.crit messages to somewhere if desired.
The config setups for rsyslog and syslog are different, as always, man pages are your friend.