setting the kernel log level

created onAugust 20, 2025

kernel log levels

Messages sent by the kernel fall into 8 categories of log levels 0 to 7, with log level 0/KERN_EMERG having the highest priority and log level 7/KERN_DEBUG having the lowest priority:

log level description
0 KERN_EMERG system is unusable
1 KERN_ALERT action must be taken immediately
2 KERN_CRIT critical conditions
3 KERN_ERR error conditions
4 KERN_WARNING warning conditions
5 KERN_NOTICE normal but significant condition
6 KERN_INFO informational
7 KERN_DEBUG debug-level messages

The system has 4 log levels configured in :

  • first log level field: the current console log level.
  • second log level field: the default message log level. For any message that has no log level associated, this log level is used.
  • third log level field: the minimum which can be used for the console log level.
  • fourth log level field: the default console log level. This is also the log level at boot time.

All Kernel Messages with a log level smaller than the console log level will be printed to the console.

displaying and setting the kernel log levels

The log levels can be displayed with :

rudolf@idoru:~$ cat /proc/sys/kernel/printk 4 4 1 4

For the configuration above, all message with log level 3/KERN_ERR will be printed to the console.

setting the console log levels directly in /proc/sys/kernel/printk

The above configuration can be set with: .

When setting the console log levels this way, not all console levels have to be provided. To just set the current console log level to ‘4’, suffices.

setting the current console level with dmesg

The current console level, first field, can also be set with , using either the numeric log level or the string log levels in the table above, lower cased, without the “KERN_” part. However, is not equivalent to . sets the log level 7 for the current console log level in :

root@idoru:/$ dmesg -n 6 root@idoru:/$ cat /proc/sys/kernel/printk 6 4 1 7 root@idoru:/$ dmesg -n info root@idoru:/$ cat /proc/sys/kernel/printk 7 4 1 7

setting the console level in the kernel command line

As anything in , this configuration is not persistent. The default console log level, fourth field, which is also used at boot time, can be set with the kernel command line parameter , i.e.

setting the console level with sysctl

The console log levels can be configured with , if contains the respective line, i.e.:

kernel.printk = 3 4 1 3

The syntax is . If the config file is omitted like in above, is used.

x