Description of kernel.printk values

31,168

Solution 1

Sysctl settings are documented in Documentation/sysctl/*.txt in the kernel source tree. On Debian, install linux-doc to have the documentation in usr/share/doc/linux-doc-*/Documentation/ (most distributions have a similar package). From Documentation/sysctl/kernel.txt:

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 loglevels.

  • 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

I don't find any clear prose explanation of what default_console_loglevel is used for. In the Linux kernel source, the kernel.printk sysctl sets console_printk. The default_console_loglevel field doesn't seem to be used anywhere.

Solution 2

Description of kernel.printk values

  • "0" → Emergency messages, system is about to crash or is unstable pr_emerg
  • "1" → Something bad happened and action must be taken immediately pr_alert
  • "2" → A critical condition occurred like a serious hardware/software failure pr_crit
  • "3" → An error condition, often used by drivers to indicate difficulties with the hardware pr_err
  • "4" → A warning, meaning nothing serious by itself but might indicate problems pr_warning
  • "5" → Nothing serious, but notably nevertheless. Often used to report security events. pr_notice
  • "6" → Informational message e.g. startup information at driver initialization pr_info
  • "7" → Debug messages pr_debug, pr_devel if DEBUG is defined
  • KERN_DEFAULT "d" The default kernel loglevel
  • KERN_CONT "" "continued" line of log printout (only done after a line that had no enclosing)
Share:
31,168

Related videos on Youtube

dribler
Author by

dribler

Real Name: Chris Francy I work as a Senior Network Analyst at Northwest Educational Service District #189 in the Technology Services department. The Technology Service department, in addition to supporting the staff at NWESD, provides network support services to 35 K-12 school districts in Northwest Washington region. In my free time, when I am not at work or answering questions, I play a lot of video games on the PC (Steam Profile).

Updated on September 18, 2022

Comments

  • dribler
    dribler over 1 year

    Between Debian 5 and 6, the default suggested value for kernel.printk in /etc/sysctl.conf was changed from kernel.printk = 4 4 1 7 to kernel.printk = 3 4 1 3. I understand that the first value corresponds to what is going to the console. What are the next 3 values for?

    Do the numerical values have the same meaning as the syslog log levels? Or do they have different definitions?

    Am I missing some documentation in my searching, or is the only location to figure this out the kernel source.

  • dribler
    dribler almost 13 years
    This Debian bug 526855, which is the origin of the change, seemed to suggest that there are some conditions where klogd may reset console_loglevel to default_console_loglevel when it calls some kernel function.
  • Gilles 'SO- stop being evil'
    Gilles 'SO- stop being evil' almost 13 years
    @Zoredache: Ah. It did back then, but no longer. The setting only stopped being used in the very kernel version shipped by the current Debian stable, which explains why the setup scripts still support it.