console_loglevel

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
console_loglevel [2018/11/23 13:24] – [Kernel source files] rpjdayconsole_loglevel [2018/11/23 15:33] (current) – [Overview] rpjday
Line 1: Line 1:
 ===== Overview ===== ===== Overview =====
  
-How to mess with ''loglevel'' at boot time.+Properties of console loglevel, and how to use it.
  
 ===== Files ===== ===== Files =====
Line 10: Line 10:
     * [[https://github.com/torvalds/linux/tree/master/include/linux|linux/]]     * [[https://github.com/torvalds/linux/tree/master/include/linux|linux/]]
       * [[https://github.com/torvalds/linux/blob/master/include/linux/printk.h|printk.h]]       * [[https://github.com/torvalds/linux/blob/master/include/linux/printk.h|printk.h]]
 +  * [[https://github.com/torvalds/linux/tree/master/lib|lib/]]
 +    * [[https://github.com/torvalds/linux/blob/master/lib/Kconfig.debug|Kconfig.debug]]
 +  * [[https://github.com/torvalds/linux/tree/master/init|init/]]
 +    * [[https://github.com/torvalds/linux/blob/master/init/main.c|main.c]]
 +  * [[https://github.com/torvalds/linux/tree/master/kernel|kernel/]]
 +    * [[https://github.com/torvalds/linux/blob/master/kernel/sysctl.c|sysctl.c]]
 +    * [[https://github.com/torvalds/linux/tree/master/kernel/printk|printk/]]
 +      * [[https://github.com/torvalds/linux/blob/master/kernel/printk/printk.c|printk.c]]
 +  * [[https://github.com/torvalds/linux/tree/master/Documentation|Documentation/]]
 +    * [[https://github.com/torvalds/linux/tree/master/Documentation/admin-guide|admin-guide/]]
 +      * [[https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/kernel-parameters.txt|parameters.txt]]
  
 ==== Running system files ==== ==== Running system files ====
  
-==== lib/Kconfig.debug ====+  * /etc/sysctl.conf 
 +  * /sys/module/printk/parameters 
 +  * /proc/sys/kernel/printk/
 + 
 +===== Kernel parameters =====
  
 <code> <code>
-config CONSOLE_LOGLEVEL_DEFAULT +loglevel=       All Kernel Messages with a loglevel smaller than the 
-        int "Default console loglevel (1-15)" +                console loglevel will be printed to the console. It can 
-        range 1 15 +                also be changed with klogd or other programs. The 
-        default "7" +                loglevels are defined as follows:
-        help +
-          Default loglevel to determine what will be printed on the console.+
  
-          Setting a default here is equivalent to passing in loglevel=<x> in +                0 (KERN_EMERG)          system is unusable 
-          the kernel bootargs. loglevel=<x> continues to override whatever +                1 (KERN_ALERT)          action must be taken immediately 
-          value is specified here as well.+                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 
 +</code>
  
-          Note: This does not affect the log level of un-prefixed printk() +<code> 
-          usage in the kernel. That is controlled by the MESSAGE_LOGLEVEL_DEFAULT +ignore_loglevel [KNL] 
-          option.+                Ignore loglevel setting this will print /all/ 
 +                kernel messages to the consoleUseful for debugging. 
 +                We also add it as printk module parameter, so users 
 +                could change it dynamically, usually by 
 +                /sys/module/printk/parameters/ignore_loglevel. 
 +</code>
  
-config MESSAGE_LOGLEVEL_DEFAULT +===== Kernel source files =====
-        int "Default message log level (1-7)" +
-        range 1 7 +
-        default "4" +
-        help +
-          Default log level for printk statements with no specified priority.+
  
-          This was hard-coded to KERN_WARNING since at least 2.6.10 but folks +==== kernel/printk/printk.c ====
-          that are auditing their logs closely may want to set it to a lower +
-          priority.+
  
-          Note: This does not affect what message level gets printed on the console +<code> 
-          by default. To change that, use loglevel=<xin the kernel bootargs+int console_printk[4] = { 
-          or pick a different CONSOLE_LOGLEVEL_DEFAULT configuration value.+ CONSOLE_LOGLEVEL_DEFAULT, /* console_loglevel */ 
 + MESSAGE_LOGLEVEL_DEFAULT, /* default_message_loglevel */ 
 + CONSOLE_LOGLEVEL_MIN, /* minimum_console_loglevel */ 
 + CONSOLE_LOGLEVEL_DEFAULT, /* default_console_loglevel */ 
 +};
 </code> </code>
  
Line 56: Line 77:
 #define CONSOLE_LOGLEVEL_SILENT  0 /* Mum's the word */ #define CONSOLE_LOGLEVEL_SILENT  0 /* Mum's the word */
 #define CONSOLE_LOGLEVEL_MIN 1 /* Minimum loglevel we let people use */ #define CONSOLE_LOGLEVEL_MIN 1 /* Minimum loglevel we let people use */
-#define CONSOLE_LOGLEVEL_QUIET 4 /* Shhh ..., when booted with "quiet" */ 
 #define CONSOLE_LOGLEVEL_DEBUG 10 /* issue debug messages */ #define CONSOLE_LOGLEVEL_DEBUG 10 /* issue debug messages */
 #define CONSOLE_LOGLEVEL_MOTORMOUTH 15 /* You can't shut this one up */ #define CONSOLE_LOGLEVEL_MOTORMOUTH 15 /* You can't shut this one up */
  
 /* /*
- * Default used to be hard-coded at 7, we're now allowing it to be set from + * Default used to be hard-coded at 7, quiet used to be hardcoded at 4, 
- kernel config.+ we're now allowing both to be set from kernel config.
  */  */
 #define CONSOLE_LOGLEVEL_DEFAULT CONFIG_CONSOLE_LOGLEVEL_DEFAULT #define CONSOLE_LOGLEVEL_DEFAULT CONFIG_CONSOLE_LOGLEVEL_DEFAULT
 +#define CONSOLE_LOGLEVEL_QUIET CONFIG_CONSOLE_LOGLEVEL_QUIET
  
 extern int console_printk[]; extern int console_printk[];
Line 83: Line 104:
  console_loglevel = CONSOLE_LOGLEVEL_MOTORMOUTH;  console_loglevel = CONSOLE_LOGLEVEL_MOTORMOUTH;
 } }
 +</code>
 +==== lib/Kconfig.debug ====
 +
 +<code>
 +config CONSOLE_LOGLEVEL_DEFAULT
 + int "Default console loglevel (1-15)"
 + range 1 15
 + default "7"
 + help
 +   Default loglevel to determine what will be printed on the console.
 +
 +   Setting a default here is equivalent to passing in loglevel=<x> in
 +   the kernel bootargs. loglevel=<x> continues to override whatever
 +   value is specified here as well.
 +
 +   Note: This does not affect the log level of un-prefixed printk()
 +   usage in the kernel. That is controlled by the MESSAGE_LOGLEVEL_DEFAULT
 +   option.
 +
 +config CONSOLE_LOGLEVEL_QUIET
 + int "quiet console loglevel (1-15)"
 + range 1 15
 + default "4"
 + help
 +   loglevel to use when "quiet" is passed on the kernel commandline.
 +
 +   When "quiet" is passed on the kernel commandline this loglevel
 +   will be used as the loglevel. IOW passing "quiet" will be the
 +   equivalent of passing "loglevel=<CONSOLE_LOGLEVEL_QUIET>"
 +
 +config MESSAGE_LOGLEVEL_DEFAULT
 + int "Default message log level (1-7)"
 + range 1 7
 + default "4"
 + help
 +   Default log level for printk statements with no specified priority.
 +
 +   This was hard-coded to KERN_WARNING since at least 2.6.10 but folks
 +   that are auditing their logs closely may want to set it to a lower
 +   priority.
 +
 +   Note: This does not affect what message level gets printed on the console
 +   by default. To change that, use loglevel=<x> in the kernel bootargs,
 +or pick a different CONSOLE_LOGLEVEL_DEFAULT configuration value.
 </code> </code>
  
  • console_loglevel.1542979456.txt.gz
  • Last modified: 2018/11/23 13:24
  • by rpjday